]> git.mxchange.org Git - shipsimu.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 18 Feb 2023 23:53:41 +0000 (00:53 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 19 Feb 2023 00:18:17 +0000 (01:18 +0100)
- exit; means normal exit which isn't the case here
- updated 'core' framework

application/shipsimu/exceptions.php
core
index.php

index 28c8fea1bc43f95b0268ef00e4f0cc90060dde6e..b8d33d8745b00daf244d65afeffdf8b28eacc29b 100644 (file)
@@ -34,6 +34,9 @@ function shipsimu_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 shipsimu developer team.' . PHP_EOL, gettype($exceptionInstance));
+               exit(255);
        }
 }
 
@@ -127,7 +135,7 @@ function shipsimu_assert_handler (string $file, int $line, int $code) {
        }
 
        // Create message
-       $message = sprintf('File: %s, Line: %d, Code: %d',
+       $message = sprintf('File: %s, Line: %s, Code: %s',
                basename($file),
                $line,
                $code
diff --git a/core b/core
index 280798f3e8db2f8d5f6d0330081ec63e04414330..f861d6bc00f8a3ecf6b057f2aa93129572643896 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 280798f3e8db2f8d5f6d0330081ec63e04414330
+Subproject commit f861d6bc00f8a3ecf6b057f2aa93129572643896
index 51a9f4758ec3a2fbdf28195223f7046ea98c1062..94177e3062c449faaa117332f0d0fac89dad4038 100644 (file)
--- 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: <span class="emergency_span">%s</span>',
-                               $message
-                       ));
+                       printf('[Main:] Emergency exit reached: <span class="emergency_span">%s</span>', $message);
+                       exit(255);
                }
        }