Skip to content

RFE - Errors should be different subclasses or have a code attached to them #695

@bpytlik

Description

@bpytlik

As far as I know, if you want to handle different classes or errors coming out of node redis differently, you have to parse the error strings. For example, if I want to treat an error caused by the redis DB still loading off disk differently than I want to treat an error caused by the host being unreachable, I have to run regular expressions over the text of the error messages. That text is not a stable interface from what I can see.

There are two ways I can think of to solve this problem (and I'm sure there are many others):

  1. Create different subclasses of Error and throw them instead of a generic error.
  2. Add a field to the Error that's thrown and have a standard list of codes (ECONNRESET, EHOSTUNREACH, LOADINGDATA, SLAVESYNCING, etc...) which are set before the error is thrown.

This would make integrating node_redis into a larger program much easier as handling the errors would use a stable interface rather than a long text string.

If I've missed some existing mechanism to distinguish between errors, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions