From c3c81f98871f2d7de24d453fba4232e08caef4cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 19 Nov 2008 19:18:06 +0000 Subject: [PATCH] Some minor improvements, typo fixed: - Typo in exception handler fixed - Application selector does now have updated starter.php and exception/assertion handlers --- application/admin/exceptions.php | 2 +- application/blog/exceptions.php | 2 +- application/selector/exceptions.php | 60 +++++++++++++++++++++++++++- application/ship-simu/exceptions.php | 2 +- application/shoutbox/exceptions.php | 2 +- application/todo/exceptions.php | 2 +- 6 files changed, 63 insertions(+), 7 deletions(-) diff --git a/application/admin/exceptions.php b/application/admin/exceptions.php index f463a9c..fd41c37 100644 --- a/application/admin/exceptions.php +++ b/application/admin/exceptions.php @@ -25,7 +25,7 @@ // Our own exception handler function __exceptionHandler (FrameworkException $e) { // Call the app_die() method - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has been terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", ApplicationHelper::getInstance()->getAppName(), ApplicationHelper::getInstance()->getAppShortName(), $e->__toString(), diff --git a/application/blog/exceptions.php b/application/blog/exceptions.php index f463a9c..fd41c37 100644 --- a/application/blog/exceptions.php +++ b/application/blog/exceptions.php @@ -25,7 +25,7 @@ // Our own exception handler function __exceptionHandler (FrameworkException $e) { // Call the app_die() method - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has been terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", ApplicationHelper::getInstance()->getAppName(), ApplicationHelper::getInstance()->getAppShortName(), $e->__toString(), diff --git a/application/selector/exceptions.php b/application/selector/exceptions.php index 228c200..fd41c37 100644 --- a/application/selector/exceptions.php +++ b/application/selector/exceptions.php @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -22,8 +22,64 @@ * along with this program. If not, see . */ +// Our own exception handler +function __exceptionHandler (FrameworkException $e) { + // Call the app_die() method + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", + ApplicationHelper::getInstance()->getAppName(), + ApplicationHelper::getInstance()->getAppShortName(), + $e->__toString(), + $e->getHexCode(), + $e->getMessage(), + $e->getPrintableBackTrace() + ), + $e->getHexCode(), + $e->getExtraData() + ); +} // END - function + // Set the new handler -//set_exception_handler('selector_exception_handler'); +set_exception_handler('__exceptionHandler'); + +// Error handler +function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) { + // Construct the message + $message = sprintf("File: %s, Line: %s, Code: %s, Message: %s", + basename($errfile), + $errline, + $errno, + $errstr + ); + + // Throw an exception here + throw new FatalErrorException($message, BaseFrameworkSystem::EXCEPTION_FATAL_ERROR); +} // END - function + +// Set error handler +set_error_handler('__errorHandler'); + +// Assertion handler +function __assertHandler ($file, $line, $code) { + // Empty code? + if ($code === "") $code = "Unknown"; + + // Create message + $message = sprintf("File: %s, Line: %s, Code: %s", + basename($file), + $line, + $code + ); + + // Throw an exception here + throw new AssertionException($message, BaseFrameworkSystem::EXCEPTION_ASSERTION_FAILED); +} // END - function + +// Init assert handling +assert_options(ASSERT_ACTIVE, 1); +assert_options(ASSERT_WARNING, 0); +assert_options(ASSERT_BAIL, 0); +assert_options(ASSERT_QUIET_EVAL, 0); +assert_options(ASSERT_CALLBACK, '__assertHandler'); // [EOF] ?> diff --git a/application/ship-simu/exceptions.php b/application/ship-simu/exceptions.php index f463a9c..fd41c37 100644 --- a/application/ship-simu/exceptions.php +++ b/application/ship-simu/exceptions.php @@ -25,7 +25,7 @@ // Our own exception handler function __exceptionHandler (FrameworkException $e) { // Call the app_die() method - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has been terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", ApplicationHelper::getInstance()->getAppName(), ApplicationHelper::getInstance()->getAppShortName(), $e->__toString(), diff --git a/application/shoutbox/exceptions.php b/application/shoutbox/exceptions.php index f463a9c..fd41c37 100644 --- a/application/shoutbox/exceptions.php +++ b/application/shoutbox/exceptions.php @@ -25,7 +25,7 @@ // Our own exception handler function __exceptionHandler (FrameworkException $e) { // Call the app_die() method - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has been terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", ApplicationHelper::getInstance()->getAppName(), ApplicationHelper::getInstance()->getAppShortName(), $e->__toString(), diff --git a/application/todo/exceptions.php b/application/todo/exceptions.php index f463a9c..fd41c37 100644 --- a/application/todo/exceptions.php +++ b/application/todo/exceptions.php @@ -25,7 +25,7 @@ // Our own exception handler function __exceptionHandler (FrameworkException $e) { // Call the app_die() method - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has been terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has terminated due to a thrown exception: %s [%s]: %s Backtrace:
%s
", ApplicationHelper::getInstance()->getAppName(), ApplicationHelper::getInstance()->getAppShortName(), $e->__toString(), -- 2.39.2