]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 18 Feb 2023 23:49:57 +0000 (00:49 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 18 Feb 2023 23:49:57 +0000 (00:49 +0100)
- exit; means normal exit of program

application/tests/exceptions.php
framework/main/classes/class_BaseFrameworkSystem.php
index.php

index a3037971253666f25f20ba7a8a0dbe11710a65b9..06acedd47625f1bc63e4e6c2e713d68e6cb4660b 100644 (file)
@@ -34,6 +34,9 @@ function core_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,9 +95,13 @@ 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
@@ -102,6 +109,7 @@ Backtrace:
                 * outputs like above.
                 */
                printf('exceptionInstance[]=%s is invalid! Please inform the core developer team.' . PHP_EOL, gettype($exceptionInstance));
+               exit(255);
        }
 }
 
index e77f645c92b4323a0beb086478c7275f8f7e980c..3920db4cfd52c89dbf75b43bbc79643128bce04f 100644 (file)
@@ -194,7 +194,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                } else {
                        // Do not call this twice
                        trigger_error(__METHOD__ . ': Called twice.');
-                       exit;
+                       exit(255);
                }
        }
 
@@ -566,7 +566,7 @@ Loaded includes:
                } else {
                        // Trigger an error
                        trigger_error($stubMessage);
-                       exit;
+                       exit(255);
                }
        }
 
@@ -841,7 +841,7 @@ Loaded includes:
                        } else {
                                // Trigger an error
                                trigger_error($message . "<br />\n");
-                               exit;
+                               exit(255);
                        }
                } else {
                        // @TODO Finish this part!
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);
                }
        }