* @version 0.0 * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ // The hub's own exception handler function hub_exception_handler ($exceptionInstance) { // Is it an object and a valid instance? if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof FrameworkException)) { // Get the regular trace $trace = $exceptionInstance->getTrace(); // Get 3 call levels $backTrace = ""; for ($idx = 0; $idx < 3; $idx++) { $traceArray = $trace[$idx]; // Convert arguments type into human-readable $args = $traceArray['args']; $argsString = ""; foreach ($args as $arg) { $argsString .= ", ".gettype($arg); } $argsString = substr($argsString, 2); $backTrace .= sprintf("---------- Pos %d: ---------- Method : %s%s%s(%s) ----- Caller: ----- File : %s Line : %d\n", ($idx + 1), $traceArray['class'], $traceArray['type'], $traceArray['function'], $argsString, basename($traceArray['file']), $traceArray['line'] ); } // Construct the message $message = sprintf("-------------------------------------------------------------------------------- Uncaught Exception : %s -------------------------------------------------------------------------------- Message : %s Code : %s File : %s Line : %d -------------------------------------------------------------------------------- Backtrace: -------------------------------------------------------------------------------- %s --------------------------------------------------------------------------------\n", trim(html_entity_decode(strip_tags($exceptionInstance->__toString()))), trim(html_entity_decode(strip_tags($exceptionInstance->getMessage()))), $exceptionInstance->getHexCode(), $exceptionInstance->getFile(), $exceptionInstance->getLine(), trim($backTrace) ); // Output the message print $message; } } // Set the new handler set_exception_handler('hub_exception_handler'); // [EOF] ?>