Continued:
[core.git] / application / tests / exceptions.php
index ea239eb594953aeb6cf3f8bfe2293ae4836192fc..e8e4bf360c1541afdcf19b5bf009bbac1831dc57 100644 (file)
@@ -27,7 +27,7 @@ use CoreFramework\Object\BaseFrameworkSystem;
 // The node's own exception handler
 function tests_exception_handler ($exceptionInstance) {
        // Is it an object and a valid instance?
-       if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof FrameworkException)) {
+       if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof Throwable)) {
                // Init variable
                $backTrace = '';
 
@@ -76,9 +76,9 @@ Backtrace:
 --------------------------------------------------------------------------------
 %s
 --------------------------------------------------------------------------------\n",
-                       trim(html_entity_decode(strip_tags($exceptionInstance->__toString()))),
+                       trim(html_entity_decode(strip_tags(get_class($exceptionInstance)))),
                        trim(html_entity_decode(strip_tags($exceptionInstance->getMessage()))),
-                       $exceptionInstance->getHexCode(),
+                       ($exceptionInstance instanceof FrameworkException ? $exceptionInstance->getHexCode() : '0x' . bin2hex($exceptionInstance->getCode())),
                        $exceptionInstance->getFile(),
                        $exceptionInstance->getLine(),
                        trim($backTrace)
@@ -86,11 +86,16 @@ Backtrace:
 
                // Output the message
                print($message);
+       } elseif (is_object($exceptionInstance)) {
+               // Output more details
+               printf('exceptionInstance=%s' . PHP_EOL, get_class($exceptionInstance));
        } else {
-               // Invalid exception instance detected! Do *only* throw exceptions that
-               // extends our own exception 'FrameworkException' to get such nice
-               // outputs like above.
-               print('exceptionInstance[]=' . gettype($exceptionInstance) . ' is invalid! Please inform the core developer team.' . PHP_EOL);
+               /*
+                * 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));
        }
 }