Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors? #43

Open
gmaclennan opened this issue Jun 22, 2017 · 2 comments · May be fixed by #44
Open

Handle errors? #43

gmaclennan opened this issue Jun 22, 2017 · 2 comments · May be fixed by #44

Comments

@gmaclennan
Copy link

There is currently no way of capturing errors from database reads, for example if permission is denied. We could add a handler to https://github.com/unfold/react-firebase/blob/master/src/connect.js#L106

subscriptionRef.on('value', update, onError)

But how to map that value to props? We could just map the value to the same prop key, which would require an additional check props[key] instanceof Error, or we could extend the mergeProps function to also pass and error argument that the user could map to props as they desire, something like (we could attach the key to the error for convenience):

const mergeProps = (ownProps, firebaseProps, error) => ({
  error: 'There was an error reading ' + error.key + ' Firebase said: ' + error.message
})
@gmaclennan gmaclennan linked a pull request Jun 22, 2017 that will close this issue
@simenbrekken
Copy link
Contributor

@gmaclennan I've taken a stab a this in https://github.com/unfold/react-firebase/tree/merge-props-error-handling if you'd like to give it a try. There's no docs yet but the added tests should be understandable enough.

@simenbrekken
Copy link
Contributor

Are you still tracking this @gmaclennan or should we go ahead without your input?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants