X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Ftests%2Fexceptions.php;h=834bc6e23fd8ea38cb11a86a2d139a969906eb2a;hb=b002c5909aa0f781505dde5414964b0f014cde01;hp=e483dafd1ee8add7fe8d61d3de1710077d7bf5b8;hpb=75d22b262f62dd88e577ade6da3d6be9d34b9930;p=core.git diff --git a/application/tests/exceptions.php b/application/tests/exceptions.php index e483dafd..834bc6e2 100644 --- a/application/tests/exceptions.php +++ b/application/tests/exceptions.php @@ -1,10 +1,15 @@ - * @version 0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team + * @version 0.0.0 + * @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 +29,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 Exception)) { // Init variable $backTrace = ''; @@ -73,9 +78,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,16 +88,21 @@ Backtrace: // Output the message print($message); + } elseif (is_object($exceptionInstance)) { + // Output more details + printf('exceptionInstance=%s', print_r($exceptionInstance, true)); } 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)); } } // Error handler -function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) { +function tests_error_handler ($errno, $errstr, $errfile, $errline, array $errcontext) { // Construct the message $message = sprintf('File: %s, Line: %s, Code: %s, Message: %s', basename($errfile), @@ -106,7 +116,7 @@ function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) } // END - function // Assertion handler -function __assertHandler ($file, $line, $code) { +function tests_assert_handler ($file, $line, $code) { // Empty code? if ($code === '') { $code = 'Unknown'; @@ -127,17 +137,14 @@ function __assertHandler ($file, $line, $code) { } // END - function // Set error handler -//set_error_handler('__errorHandler'); +//set_error_handler('tests_error_handler'); // Set the new handler set_exception_handler('tests_exception_handler'); // Init assert handling -assert_options(ASSERT_ACTIVE , TRUE); -assert_options(ASSERT_WARNING , FALSE); -assert_options(ASSERT_BAIL , TRUE); -assert_options(ASSERT_QUIET_EVAL, FALSE); -assert_options(ASSERT_CALLBACK , '__assertHandler'); - -// [EOF] -?> +assert_options(ASSERT_ACTIVE , true); +assert_options(ASSERT_WARNING , false); +assert_options(ASSERT_BAIL , true); +assert_options(ASSERT_QUIET_EVAL, false); +assert_options(ASSERT_CALLBACK , 'tests_assert_handler');