diff --git a/src/php_error.php b/src/php_error.php index 3953ec3..5cd5fa4 100644 --- a/src/php_error.php +++ b/src/php_error.php @@ -524,6 +524,29 @@ class ErrorHandler T_UNSET => 'syntax-function' ); + /** + * A mapping of PHP errors, + * mapped to descriptions of them. + */ + private static $PHP_ERROR_MAPPINGS = array( + E_ERROR => 'E_ERROR', + E_WARNING => 'E_WARNING', + E_PARSE => 'E_PARSE', + E_NOTICE => 'E_NOTICE', + E_CORE_ERROR => 'E_CORE_ERROR', + E_CORE_WARNING => 'E_CORE_WARNING', + E_COMPILE_ERROR => 'E_COMPILE_ERROR', + E_COMPILE_WARNING => 'E_COMPILE_WARNING', + E_USER_ERROR => 'E_USER_ERROR', + E_USER_WARNING => 'E_USER_WARNING', + E_USER_NOTICE => 'E_USER_NOTICE', + E_STRICT => 'E_STRICT', + E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', + E_DEPRECATED => 'E_DEPRECATED', + E_USER_DEPRECATED => 'E_USER_DEPRECATED', + E_ALL => 'E_ALL' + ); + /** * A list of methods which are known to call the autoloader, * but should not error, if the class is not found. @@ -1142,6 +1165,7 @@ public static function identifyTypeHTML( $arg, $recurseLevels=1 ) { private $defaultErrorReportingOff; private $applicationRoot; private $serverName; + private $showErrorCode; private $catchClassNotFound; private $catchSurpressedErrors; @@ -1226,6 +1250,8 @@ public static function identifyTypeHTML( $arg, $recurseLevels=1 ) { * - enable_saving Can be true or false. When true, saving files is enabled, and when false, it is disabled. * Defaults to true! * + * - show_error_code Can be true or false. When true php error codes are shown in the actual error message. + * Defaults to false. * @param options Optional, an array of values to customize this handler. * @throws Exception This is raised if given an options that does *not* exist (so you know that option is meaningless). */ @@ -1268,6 +1294,7 @@ public function __construct( $options=null ) { $this->applicationRoot = ErrorHandler::optionsPop( $options, 'application_root' , $_SERVER['DOCUMENT_ROOT'] ); $this->serverName = ErrorHandler::optionsPop( $options, 'server_name' , $_SERVER['SERVER_NAME'] ); + $this->showErrorCode = ErrorHandler::optionsPop( $options, 'show_error_code' , false); /* * Relative paths might be given for document root, @@ -2493,7 +2520,7 @@ public function reportError( $code, $message, $errLine, $errFile, $ex=null ) { $_SERVER ); - $this->displayError( $message, $srcErrLine, $errFile, $errFileType, $stackTrace, $fileLinesSets, $numFileLines, $dump ); + $this->displayError( $message, $srcErrLine, $errFile, $errFileType, $stackTrace, $fileLinesSets, $numFileLines, $dump, $code ); // exit in order to end processing $this->turnOff(); @@ -3224,13 +3251,15 @@ private function displayJSInjection() { * The actual display logic. * This outputs the error details in HTML. */ - private function displayError( $message, $errLine, $errFile, $errFileType, $stackTrace, &$fileLinesSets, $numFileLines, $dumpInfo ) { + private function displayError( $message, $errLine, $errFile, $errFileType, $stackTrace, &$fileLinesSets, $numFileLines, $dumpInfo, $code ) { $applicationRoot = $this->applicationRoot; $serverName = $this->serverName; $backgroundText = $this->backgroundText; $displayLineNumber = $this->displayLineNumber; $saveUrl = $this->saveUrl; $isSavingEnabled = $this->isSavingEnabled; + $showErrorCode = $this->showErrorCode; + $codeDescription = ErrorHandler::$PHP_ERROR_MAPPINGS[$code]; /* * When a query string is not provided, @@ -3267,7 +3296,10 @@ function() use ( &$fileLinesSets, $numFileLines, $displayLineNumber, $dumpInfo, - $isSavingEnabled + $isSavingEnabled, + $showErrorCode, + $code, + $codeDescription ) { if ( $backgroundText ) { ?>
@@ -3286,6 +3318,7 @@ function() use (

+ ".$codeDescription." (".$code.")" : ""); ?>

@@ -3597,7 +3630,8 @@ function displayHTML( Closure $head, $body=null, $javascript=null ) { } h1, - h2 { + h2, + h3 { font-family: "Segoe UI Light","Helvetica Neue",'RobotoLight',"Segoe UI","Segoe WP",sans-serif; font-weight: 100; line-height: normal; @@ -3729,6 +3763,12 @@ function displayHTML( Closure $head, $body=null, $javascript=null ) { position: relative; white-space: pre-wrap; } + + #error-code { + font-size: 14px; + margin-bottom: 0px; + margin-top: 0px; + }