X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fship-simu%2Fexceptions.php;h=c6310a399a2863fb923e1b743a714deb61c76631;hb=a2cc983f5fe910115d25800c258875a3919fb143;hp=98989ee11b992d4e64f4dd16443e53d3e361089f;hpb=75552231db513fd6657bdb232c5f3109aaa605d7;p=shipsimu.git diff --git a/application/ship-simu/exceptions.php b/application/ship-simu/exceptions.php index 98989ee..c6310a3 100644 --- a/application/ship-simu/exceptions.php +++ b/application/ship-simu/exceptions.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -25,14 +25,18 @@ // 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. Backtrace:
%s
", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has been 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('__exceptionHandler'); @@ -49,10 +53,33 @@ function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) // 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] ?>