exceptions.php

Go to the documentation of this file.
00001 <?php
00025 // Our own exception handler
00026 function __exceptionHandler (FrameworkException $e) {
00027         // Call the app_die() method
00028         ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> (<span class=\"app_short_name\">%s</span>) has terminated due to a thrown exception: <span class=\"exception_name\">%s</span> <span class=\"exception_number\">[%s]</span>: <span class=\"debug_exception\">%s</span> Backtrace: <div class=\"debug_backtrace\">%s</div>",
00029                 ApplicationHelper::getInstance()->getAppName(),
00030                 ApplicationHelper::getInstance()->getAppShortName(),
00031                 $e->__toString(),
00032                 $e->getHexCode(),
00033                 $e->getMessage(),
00034                 $e->getPrintableBackTrace()
00035         ),
00036                 $e->getHexCode(),
00037                 $e->getExtraData()
00038         );
00039 } // END - function
00040 
00041 // Set the new handler
00042 set_exception_handler('__exceptionHandler');
00043 
00044 // Error handler
00045 function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) {
00046         // Construct the message
00047         $message = sprintf("File: <span class=\"debug_file\">%s</span>, Line: <span class=\"debug_line\">%s</span>, Code: <span class=\"debug_code\">%s</span>, Message: <span class=\"debug_message\">%s</span>",
00048                 basename($errfile),
00049                 $errline,
00050                 $errno,
00051                 $errstr
00052         );
00053 
00054         // Throw an exception here
00055         throw new FatalErrorException($message, BaseFrameworkSystem::EXCEPTION_FATAL_ERROR);
00056 } // END - function
00057 
00058 // Set error handler
00059 set_error_handler('__errorHandler');
00060 
00061 // Assertion handler
00062 function __assertHandler ($file, $line, $code) {
00063         // Empty code?
00064         if ($code === "") $code = "<em>Unknown</em>";
00065 
00066         // Create message
00067         $message = sprintf("File: <span class=\"debug_file\">%s</span>, Line: <span class=\"debug_line\">%s</span>, Code: <span class=\"debug_code\">%s</span>",
00068                 basename($file),
00069                 $line,
00070                 $code
00071         );
00072 
00073         // Throw an exception here
00074         throw new AssertionException($message, BaseFrameworkSystem::EXCEPTION_ASSERTION_FAILED);
00075 } // END - function
00076 
00077 // Init assert handling
00078 assert_options(ASSERT_ACTIVE,     1);
00079 assert_options(ASSERT_WARNING,    0);
00080 assert_options(ASSERT_BAIL,       0);
00081 assert_options(ASSERT_QUIET_EVAL, 0);
00082 assert_options(ASSERT_CALLBACK,   '__assertHandler');
00083 
00084 // [EOF]
00085 ?>

Generated on Mon Dec 8 01:06:44 2008 for Ship-Simulator by  doxygen 1.5.6