X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fmxchange%2Fexceptions.php;h=fd41c37727663bfd3d5e82c4f31870119eaa3f99;hb=7940f3ad709afe4ba58012aa835c82cecc9328cc;hp=452153a72382bc62dd8e61ab0b19037581397f99;hpb=f1d358441b193b364d57788d660e6649d0229ca6;p=mailer.git diff --git a/application/mxchange/exceptions.php b/application/mxchange/exceptions.php index 452153a723..fd41c37727 100644 --- a/application/mxchange/exceptions.php +++ b/application/mxchange/exceptions.php @@ -1,13 +1,12 @@ - * @version 0.3.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @author Roland Haeder + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version - * @link http://www.mxchange.org + * @link http://www.ship-simu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,11 +19,67 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ +// Our own exception handler +function __exceptionHandler (FrameworkException $e) { + // Call the app_die() method + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has 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('selector_exception_handler'); +set_exception_handler('__exceptionHandler'); + +// 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 + +// 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] ?>