Skip to content

Instantly share code, notes, and snippets.

@ben-z
Last active August 7, 2016 15:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ben-z/3fb281653ed061bda030 to your computer and use it in GitHub Desktop.
Save ben-z/3fb281653ed061bda030 to your computer and use it in GitHub Desktop.
HHVM Error Handling - Error display in browser
<?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