X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fhub%2Fexceptions.php;fp=application%2Fhub%2Fexceptions.php;h=62fb49cb9c3fde1e46fdefaa2f325a62afa224ef;hb=ca8b7f82b8d488b2a6766ca02fe6de767128be31;hp=3e621fa94200ef54a237c33305758ab592507d29;hpb=ac935ea4af728a7988682cabb0e9959e0c0162eb;p=hub.git diff --git a/application/hub/exceptions.php b/application/hub/exceptions.php index 3e621fa94..62fb49cb9 100644 --- a/application/hub/exceptions.php +++ b/application/hub/exceptions.php @@ -94,8 +94,48 @@ 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'; + + // 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, 1); +assert_options(ASSERT_WARNING, 0); +assert_options(ASSERT_BAIL, 0); +assert_options(ASSERT_QUIET_EVAL, 0); +assert_options(ASSERT_CALLBACK, '__assertHandler'); + // [EOF] ?>