-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add disableErrorHandler option #8
base: master
Are you sure you want to change the base?
Conversation
It looks like this adds an option to the method that cancels an existing option that came from the constructor. I think that overriding the error handler would be a better fit, or even just having your code use two clients, one with an error handler and one without. |
@trevorah We would need two clients and this is the route we opted for in our skype (@suprememoocow and I) |
@@ -158,7 +158,7 @@ Client.prototype = { | |||
}); | |||
|
|||
/* Custom error handler */ | |||
if (this.errorHandler) { | |||
if (!options.disableErrorHandler && this.errorHandler) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but a more flexible approach might be to allow the caller to intercept the error before the global error handler kicks in.
So, something like:
// Install local error handler
if (options.errorHandler) {
promise = promise.catch(options.errorHandler);
}
// Install global error handler
if (this.errorHandler) {
promise = promise.catch(this.errorHandler);
}
return promise;
This way, you get given the option to swallow the error locally before the global error handler gets called. So, this gives you flexibility to ignore the error, conditionally ignore certain errors or throw a different type of error.
627cd11
to
91a27c7
Compare
Add
disableErrorHandler
errorHandler
optionUsed in https://github.com/troupe/gitter-webapp/pull/2485
Todo