Skip to content
Snippets Groups Projects
Commit 2a489e0c authored by Olav Morken's avatar Olav Morken
Browse files

_include.php: Improve handling of unhandled errors and exceptions.

This patch adds an exception handler which will catch all unhandled
exceptions and display an error page to the user. It also adds a
handler for PHP errors and warnings. This handler will show a stacktrace
of the error, and then pass the error to the normal PHP error handler.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1561 44740490-163a-0410-bde0-09ae8108e29a
parent c2d284c5
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,26 @@ if(get_magic_quotes_gpc()) { ...@@ -22,6 +22,26 @@ if(get_magic_quotes_gpc()) {
/* Initialize the autoloader. */ /* Initialize the autoloader. */
require_once(dirname(dirname(__FILE__)) . '/lib/_autoload.php'); require_once(dirname(dirname(__FILE__)) . '/lib/_autoload.php');
/* Show error page on unhandled exceptions. */
function SimpleSAML_exception_handler(Exception $exception) {
$e = new SimpleSAML_Error_Error('UNHANDLEDEXCEPTION', $exception);
$e->show();
}
set_exception_handler('SimpleSAML_exception_handler');
/* Log full backtrace on errors and warnings. */
function SimpleSAML_error_handler($errno, $errstr, $errfile = NULL, $errline = 0, $errcontext = NULL) {
/* Show an error with a full backtrace. */
$e = new SimpleSAML_Error_Exception('Error ' . $errno . ' - ' . $errstr);
$e->logError();
/* Resume normal error processing. */
return FALSE;
}
set_error_handler('SimpleSAML_error_handler');
$path_extra = dirname(dirname(__FILE__)) . '/lib'; $path_extra = dirname(dirname(__FILE__)) . '/lib';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment