2 // The hub's own exception handler
3 function hub_exception_handler ($exceptionInstance) {
4 // Is it an object and a valid instance?
5 if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof FrameworkException)) {
6 // Get the regular trace
7 $trace = $exceptionInstance->getTrace();
11 for ($idx = 0; $idx < 3; $idx++) {
12 $traceArray = $trace[$idx];
14 // Convert arguments type into human-readable
15 $args = $traceArray['args'];
17 foreach ($args as $arg) {
18 $argsString .= ", ".gettype($arg);
20 $argsString = substr($argsString, 2);
22 $backTrace .= sprintf("---------- Pos %d: ----------
30 $traceArray['function'],
32 basename($traceArray['file']),
37 // Construct the message
38 $message = sprintf("--------------------------------------------------------------------------------
39 Uncaught Exception : %s
40 --------------------------------------------------------------------------------
45 --------------------------------------------------------------------------------
47 --------------------------------------------------------------------------------
49 --------------------------------------------------------------------------------\n",
50 trim(html_entity_decode(strip_tags($exceptionInstance->__toString()))),
51 trim(html_entity_decode(strip_tags($exceptionInstance->getMessage()))),
52 $exceptionInstance->getHexCode(),
53 $exceptionInstance->getFile(),
54 $exceptionInstance->getLine(),
63 // Set the new handler
64 set_exception_handler('hub_exception_handler');