]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/exceptions.php
CAPTCHA support basicly finished (weak CAPTCHA!)
[shipsimu.git] / application / ship-simu / exceptions.php
index 6d606d9be93a8a8e4af0bdd36ef01b16abebb2b7..69f0d9aa73bcecd7e90e6bd19455440f93a5e1c0 100644 (file)
 // Our own exception handler
 function __exceptionHandler (FrameworkException $e) {
        // Call the app_die() method
-       ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> (<strong>%s</strong>) has been terminated due to a thrown exception: <strong>%s[%s]: <span id=\"debug_exception\">%s</em></strong>. Backtrace: <div id=\"debug_backtrace\">%s</div>",
+       ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> (<strong>%s</strong>) has been terminated due to a thrown exception: <span id=\"exception_name\">%s</span> <span id=\"exception_number\">[%s]</span>: <span id=\"debug_exception\">%s</span> Backtrace: <div id=\"debug_backtrace\">%s</div>",
                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');
@@ -50,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 = "<em>Unknown</em>";
+
+       // Create message
+       $message = sprintf("File: <span id=\"debug_file\">%s</span>, Line: <span id=\"debug_line\">%s</span>, Code: <span id=\"debug_code\">%s</span>",
+               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]
 ?>