-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
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):
- Create different subclasses of Error and throw them instead of a generic error.
- 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.