Display fatal / browser error notifications

Well, I just started with hhvm / hack. But I wanted to display errors in the browser, but it did not work.

I set the ini options as follows

error_reporting(E_ALL); ini_set('display_errors', '1'); 

According to the var_dump ini_get parameter, the values ​​were set to

 string(5) "32767" string(1) "1" 

But when I did

 <?hh error_reporting(E_ALL); ini_set('display_errors', '1'); throw new InvalidArgumentException('test'); 

When I visited the page through a browser, I would just get a white screen and 500 http headers. Therefore, no explanation for fatal error / exclusion exists.

If I were going through the terminal hhvm index.php It would show:

 Fatal error: Uncaught exception 'InvalidArgumentException' with message 'test' in /var/www/public/index.php:3 Stack trace: #0 {main} 

So now the question. How does this happen? I do not receive any messages in the browser, but do in cli? And secondly, how can I make it work in the browser to show messages.

I came across this question and this . But first, well, the same thing, but without an answer. And the second says something about static validation. IE, what int is given, etc. At least that is what I think it means.

Another question I came, which looked like me, but again did not answer.

And according to the docs it should work, I think.

Read more about the documents I received through

Although display_errors can be set at runtime (with the ini_set () function), this will not affect if the script has fatal errors. This is because the desired action is not performed at runtime.

So, I thought the exception was a fatal error, so I just made $test = $bar + 1;

Let it be in cli <

 Notice: Undefined variable: bar in /var/www/public/index.php on line 8 int(1) 

Again in the browser

 int(1) 

Therefore, I also do not receive notifications.

When I restart hhvm service hhvm restart , I also get the error Log file not specified under daemon mode. error Log file not specified under daemon mode. don't know if he has anything to do with him

+8
hhvm
source share
2 answers

Well, that took me on a quest, but finally found the answer, see this github post . However, it cannot display fatal errors. But notifications are displayed

So, I wrote my own error handler; it is not complete, but does the job at the moment.

Warning, do not check ini display_errors

 set_error_handler(function ($errorNumber, $message, $errfile, $errline) { switch ($errorNumber) { case E_ERROR : $errorLevel = 'Error'; break; case E_WARNING : $errorLevel = 'Warning'; break; case E_NOTICE : $errorLevel = 'Notice'; break; default : $errorLevel = 'Undefined'; } echo '<br/><b>' . $errorLevel . '</b>: ' . $message . ' in <b>'.$errfile . '</b> on line <b>' . $errline . '</b><br/>'; }); 
+6
source share

You can return to php when hhvm fails. Pretty simple to do this is https://bjornjohansen.no/hhvm-with-fallback-to-php . I understand that you can attach php fallback to the error code (e.g. 404). Is it not possible to return to a php server that displays a page that loads the hhvm error log?

+1
source share

All Articles