Skip to content

Commit

Permalink
Catch fatal errors and log them
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Apr 1, 2014
1 parent 6c80ab4 commit 2b5a414
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions framework/Core/lib/Horde/ErrorHandler.php
Expand Up @@ -182,4 +182,21 @@ static public function errorHandler($errno, $errstr, $errfile, $errline,
} catch (Exception $e) {}
}

/**
* Catch fatal errors.
*/
static public function catchFatalError()
{
$error = error_get_last();
if ($error['type'] == E_ERROR) {
self::fatal(new ErrorException(
$error['message'],
0,
$error['type'],
$error['file'],
$error['line']
));
}
}

}
3 changes: 3 additions & 0 deletions horde/lib/core.php
Expand Up @@ -65,3 +65,6 @@

/* Catch errors. */
set_error_handler(array('Horde_ErrorHandler', 'errorHandler'), E_ALL | E_STRICT);

/* Catch fatal errors. */
register_shutdown_function(array('Horde_ErrorHandler', 'catchFatalError'));

0 comments on commit 2b5a414

Please sign in to comment.