-
Notifications
You must be signed in to change notification settings - Fork 3k
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
custom exception handler cannot use exit or die #4055
Comments
Your example is consistent with php, see http://3v4l.org/SgHf0 Maybe your sample should use |
Yeah, I just make a mistake |
I see, now we have something to reproduce the incompatibility |
This is a KP. You need to set |
If you mean hhvm.log.always_log_unhandled_exceptions, I have set it to false. |
I'll dig into it. |
works as expected (= zend) for me on master, it just outputs |
But I got
with that command. |
@Max-Sum I can't repro either
|
Well I can get the right result now from cli, but I still get wrong one from fast-cgi. |
…bleHipHopSyntax Summary: By turning these off by default, we should match Zend behavior better on fatals with custom error handlers. Few examples: ``` set_error_handler(function () { echo 'hello'; }); invalid(); ``` This should produce only a fatal error message without calling user handler. ``` set_error_handler(function () { echo 'hello'; }); echo $invalid; ``` This should call user handler without producing notice message. ``` set_exception_handler(function () { echo 'hello'; }); throw new Exception(); ``` This should call user handler without producing fatal error message. Relates to #3019 and #4055. Closes #4066 Reviewed By: @ptarjan Differential Revision: D1640294 Signature: t1:1640294:1414638838:69aa654fbc4b805b3f1731d786a4e0ad338d29aa
I just ran this on a fastcgi server, I'm not seeing anything in my error log, looks fine to me. Could you provide more details about what you expect to see? |
Yesterday i'll run into the same problem. Create 2 testfiles: <?php
set_exception_handler (function ($e){
echo 'Exception thrown...';
});
throw new Exception('Error');
?> First one you get exactly what you expect: Return is just "Exception thrown..." <?php
set_exception_handler (function ($e){
echo 'exception thrown...';
exit();
});
throw new Exception('Error');
?> the result is an empty page. Using instead the CLI it works as expected. |
I believe this is due to a lack of implicit flush, you could try |
Seams to work. |
参见https://github.com/facebook/hhvm/issues/4055, throw new Exception后注册的事件内不可退出。
Related to this issue facebook/hhvm#4055
implicit_flush is the right direction. If you flush() before exit() HHVM behaves the same as PHP. Interestingly this issue only occurs in callbacks registered with set_exception_handlers - not in regular code. <?php
set_exception_handler("custom_exception_handler");
function custom_exception_handler($e){
echo "I need to get flushed!";
flush(); // happens implicitly with PHP, but not with HHVM.
exit;
}
throw new Exception("bar");
?> Note the difference, when no exception handler is used: <?php
echo "I am flushed anyway";
exit; // flush() implicitly called with PHP+HHVM
?> |
I'm curious, why was this issue closed? |
example:
will throw
The text was updated successfully, but these errors were encountered: