Skip to content

Better documentation for catching errors #42

Description

@puchm

I tried to figure out how to catch a connection error which was already mentioned in several other issues. Apparently, the way to do it is:

const emitter = redis();
emitter.state.once('error', () => console.log(error))

This has a problem though: state is not in the type definitions - I just found out about this by looking at the test file. It also took way too long to find out about this so it should be documented in a better way.

I would propose

  1. adding a section to the Readme documenting this
  2. one of the following possibilities regarding state not being in the type defs
    1. Adding state to type defs
    2. Adding a separate function to the type defs, e.g. onError (if you don't want to expose the EventEmitter like that)
    3. Somehow redirecting the events that go to state so that they can be caught with emitter.on.

What do you think would be best?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions