Last active
August 7, 2016 15:07
-
-
Save ben-z/3fb281653ed061bda030 to your computer and use it in GitHub Desktop.
HHVM Error Handling - Error display in browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom error handling for hhvm | |
* Implemented in EPSInventory-API(https://github.com/epsclubs/EPSInventory-API) on Jan 5, 2015 | |
* Referenced from: http://stackoverflow.com/questions/24524222/display-fatal-notice-errors-in-browser | |
*/ | |
// Usage: Call `set_error_handler(error_handler);` at the top of any php or hh file running on hhvm | |
set_error_handler(error_handler); | |
function error_handler ($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/>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment