From: Roland Häder Date: Sat, 18 Feb 2023 23:54:16 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=751ef401c67554c820dccae5c97cea5172f9a23f;p=hub.git Continued: - exit; means normal exit which isn't the case here - updated 'core' framework --- diff --git a/application/hub/exceptions.php b/application/hub/exceptions.php index 6e8fd9f70..b8c7e4572 100644 --- a/application/hub/exceptions.php +++ b/application/hub/exceptions.php @@ -10,7 +10,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Hub Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Hub Developer Team * @license GNU GPL 3.0 or any newer version * * This program is free software: you can redistribute it and/or modify @@ -34,6 +34,9 @@ function hub_exception_handler ($exceptionInstance) { // Init variable $backTrace = ''; + // Generate exception code + $exceptionCode = ($exceptionInstance instanceof FrameworkException ? $exceptionInstance->getHexCode() : '0x' . bin2hex($exceptionInstance->getCode())); + // Get all call levels from backtrace foreach ($exceptionInstance->getTrace() as $idx => $traceArray) { // Init argument string @@ -84,7 +87,7 @@ Backtrace: --------------------------------------------------------------------------------\n", trim(html_entity_decode(strip_tags(get_class($exceptionInstance)))), trim(html_entity_decode(strip_tags($exceptionInstance->getMessage()))), - ($exceptionInstance instanceof FrameworkException ? $exceptionInstance->getHexCode() : '0x' . bin2hex($exceptionInstance->getCode())), + $exceptionCode, $exceptionInstance->getFile(), $exceptionInstance->getLine(), trim($backTrace) @@ -92,16 +95,21 @@ Backtrace: // Output the message print($message); + + // Exit with code + exit(hexdec($exceptionCode)); } elseif (is_object($exceptionInstance)) { // Output more details printf('exceptionInstance=%s', print_r($exceptionInstance, true)); + exit(255); } else { /* * Invalid exception instance detected! Do *only* throw exceptions that * extends our own exception 'FrameworkException' to get such nice * outputs like above. */ - printf('exceptionInstance[]=%s is invalid! Please inform the core developer team.' . PHP_EOL, gettype($exceptionInstance)); + printf('exceptionInstance[]=%s is invalid! Please inform the hub developer team.' . PHP_EOL, gettype($exceptionInstance)); + exit(255); } } diff --git a/core b/core index 1287590bb..f861d6bc0 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 1287590bb4dff94252b1c45f320d93ce65eb5495 +Subproject commit f861d6bc00f8a3ecf6b057f2aa93129572643896 diff --git a/index.php b/index.php index 51a9f4758..94177e306 100644 --- a/index.php +++ b/index.php @@ -62,7 +62,8 @@ final class ApplicationEntryPoint { // Is this method already called? if (isset($GLOBALS['app_die_called'])) { // Then output the text directly - exit($message); + print $message . PHP_EOL; + exit(255); } // This method shall not be called twice @@ -80,7 +81,7 @@ final class ApplicationEntryPoint { // Do we have debug installation? if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) { // Abort here - exit; + exit(255); } // Get some instances @@ -173,16 +174,16 @@ final class ApplicationEntryPoint { $responseInstance->flushBuffer(); } catch (FileNotFoundException $e) { // Even the template 'emergency_exit' wasn't found so output both message - exit($message . ', exception: ' . $e->getMessage()); + print ($message . ', exception: ' . $e->getMessage() . PHP_EOL); + exit($e->getCode()); } // Good bye... - exit; + exit(255); } else { // Output message and die - die(sprintf('[Main:] Emergency exit reached: %s', - $message - )); + printf('[Main:] Emergency exit reached: %s', $message); + exit(255); } }