Display fatal/notice errors in browser

前端 未结 2 1555
遇见更好的自我
遇见更好的自我 2021-01-05 04:38

Well I just started with hhvm/hack. But I wanted to display the errors to the browser but didnot got it working.

I set the ini settings as followed

e         


        
相关标签:
2条回答
  • 2021-01-05 04:54

    Well it took me some searching but finally found the answer, see this github post. It can't however display fatal errors. But notices are displayed

    So I wrote my own error handler; it is not complete but does the job for now.

    Warning, no check for 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/>';
    });
    
    0 讨论(0)
  • 2021-01-05 05:01

    It's possible to fall back to php when hhvm fails. Pretty simple to do that - https://bjornjohansen.no/hhvm-with-fallback-to-php. I understand you can attach php fallback per error code (like 404). So isn't it possible to fall back to php server that shows a page which loads the hhvm error log?

    0 讨论(0)
提交回复
热议问题