-
Notifications
You must be signed in to change notification settings - Fork 3
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
Error handler might still bubble up #42
Comments
If there is an error happening. Well, if someone is writing code which emits errors … |
@bwoebi What's your point? |
Just to be clear, you're suggesting that error handlers such as the one below will still cause errors to bubble up from promise callbacks. set_error_handler(function ($errno, $errstr) {
throw new \ErrorException($errstr, 0, $errno);
}); I don't think theres any way to prevent this other than calling It might be best to just wrap the current try/catch block with the following: try {
// Current try/catch block invoking error handler.
} catch (\Throwable $exception) {
// Should we write to STDERR or just exit?
if (\is_resource(STDERR)) { // STDERR could have been closed, so to avoid more error madness...
\fwrite(STDERR, "It's not nice to throw things!\n");
}
exit(1);
} catch (\Exception $exception) {
// Since we're still PHP 5.x compatible.
if (\is_resource(STDERR)) {
\fwrite(STDERR, "It's not nice to throw things!\n");
}
exit(1);
} |
Bluebird does in fact just the same, I'm just not sure about the exit code. https://github.com/petkaantonov/bluebird/blob/master/src/async.js#L49-L57 |
We should probably just use |
While I'm still strongly against using an exit in our error handlers, #43 solves it decently assuming the behavior will also be documented in the readme that implementers should avoid this edge case at all cost 👍 |
@WyriHaximus I've added a section to the README in the PR. I don't see a way to avoid |
Exceptions forwarded to
ErrorHandler
might still bubble up if an error handler is set withset_error_handler
and that one throws. Is there any reasonable way to prevent that except for callingexit;
directly?The text was updated successfully, but these errors were encountered: