X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Ftests%2Fexceptions.php;h=e8e4bf360c1541afdcf19b5bf009bbac1831dc57;hb=4ef89c509993560a05ccdb56d02e2884510ec2de;hp=b3a9b0c99d9a00d59a36d7f07cbdb5d65bf5b422;hpb=d26e71af1e28dc1429823bdec244df6303f9b2fb;p=core.git diff --git a/application/tests/exceptions.php b/application/tests/exceptions.php index b3a9b0c9..e8e4bf36 100644 --- a/application/tests/exceptions.php +++ b/application/tests/exceptions.php @@ -1,10 +1,13 @@ * @version 0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team * @license GNU GPL 3.0 or any newer version * * This program is free software: you can redistribute it and/or modify @@ -24,7 +27,7 @@ // 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 = ''; @@ -73,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) @@ -83,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.'); + /* + * 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)); } } @@ -138,6 +146,3 @@ assert_options(ASSERT_WARNING , FALSE); assert_options(ASSERT_BAIL , TRUE); assert_options(ASSERT_QUIET_EVAL, FALSE); assert_options(ASSERT_CALLBACK , '__assertHandler'); - -// [EOF] -?>