]> git.mxchange.org Git - shipsimu.git/blobdiff - application/shipsimu/exceptions.php
Continued:
[shipsimu.git] / application / shipsimu / exceptions.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