X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fhub%2Fexceptions.php;h=db2f3c44c6f7dae28a7b7c686ae265e64ca93cb9;hb=e586e6b83e93be2d686afdf2224f2aff174ca5a6;hp=3e621fa94200ef54a237c33305758ab592507d29;hpb=2efc7a1a33e9c7112100e7807c62de448d97e8f1;p=hub.git diff --git a/application/hub/exceptions.php b/application/hub/exceptions.php index 3e621fa94..db2f3c44c 100644 --- a/application/hub/exceptions.php +++ b/application/hub/exceptions.php @@ -2,10 +2,9 @@ /** * An include file for setting up the exception handler of the hub * - * * @author Roland Haeder * @version 0.0 - * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009, 2010 Hub Developer Team + * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2011 Hub Developer Team * @license GNU GPL 3.0 or any newer version * * This program is free software: you can redistribute it and/or modify @@ -22,7 +21,7 @@ * along with this program. If not, see . */ -// The hub's own exception handler +// The node's own exception handler function hub_exception_handler ($exceptionInstance) { // Is it an object and a valid instance? if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof FrameworkException)) { @@ -94,8 +93,50 @@ Backtrace: } } +// 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 + +// Assertion handler +function __assertHandler ($file, $line, $code) { + // Empty code? + if ($code === '') { + $code = 'Unknown'; + } // END - if + + // 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 + +// Set error handler +//set_error_handler('__errorHandler'); + // Set the new handler set_exception_handler('hub_exception_handler'); +// Init assert handling +assert_options(ASSERT_ACTIVE, true); +assert_options(ASSERT_WARNING, false); +assert_options(ASSERT_BAIL, false); +assert_options(ASSERT_QUIET_EVAL, false); +assert_options(ASSERT_CALLBACK, '__assertHandler'); + // [EOF] ?>