]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/exceptions.php
Simple exception handler and error handler added, profile update added with stubs
[shipsimu.git] / application / ship-simu / exceptions.php
index 7f3ddcae547ce8affe5ed75d4a15c709ac16598f..98989ee11b992d4e64f4dd16443e53d3e361089f 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
+// 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: <span id=\"debug_exception\">%s</em></strong>. Backtrace: <div id=\"debug_backtrace\">%s</div>",
+               ApplicationHelper::getInstance()->getAppName(),
+               ApplicationHelper::getInstance()->getAppShortName(),
+               $e->__toString(),
+               $e->getMessage(),
+               $e->getPrintableBackTrace()
+       ));
+}
+
 // Set the new handler
-//set_exception_handler('shipsimu_exception_handler');
+set_exception_handler('__exceptionHandler');
+
+// Error handler
+function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) {
+       // Construct the message
+       $message = sprintf("File: <span id=\"debug_file\">%s</span>, Line: <span id=\"debug_line\">%s</span>, Code: <span id=\"debug_code\">%s</span>, Message: <span id=\"debug_message\">%s</span>",
+               basename($errfile),
+               $errline,
+               $errno,
+               $errstr
+       );
+
+       // Throw an exception here
+       throw new FatalErrorException($message, BaseFrameworkSystem::EXCEPTION_FATAL_ERROR);
+}
+
+// Set error handler
+set_error_handler('__errorHandler');
 
 // [EOF]
 ?>