Skip to content

Handle errors? #43

Open
Open
@gmaclennan

Description

@gmaclennan

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
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions