function print_exception_trace_js($e) { if (!$e) { return "null"; } if (!$e instanceof Exception) { return "Not exception: " . get_class($e) . ": " . print_r($e, true) . ""; } $string = ""; $string .= $e->getMessage() . " (" . get_class($e) . ")\n"; $string .= "* " . $e->getFile() . "#" . $e->getLine() . "\n"; foreach ($e->getTrace() as $e2) { $string .= " * " . $e2['file'] . "#" . $e2['line'] . ": " . $e2['function'] . (isset($e2['args']) ? format_args_list($e2['args']) : "") . "\n"; } if ($e->getPrevious()) { $string .= "Caused by:"; $string .= print_exception_trace($e->getPrevious()); $string .= "\n"; } $string .= "\n"; return $string; }
function print_exception_trace_js($e) { if (!$e) { return "null"; } if (!$e instanceof Exception) { return "Not exception: " . get_class($e) . ": " . print_r($e, true) . ""; } $result = array(); $result['message'] = $e->getMessage(); $result['class'] = get_class($e); $result['file'] = $e->getFile(); $result['line'] = $e->getLine(); $result['trace'] = array(); foreach ($e->getTrace() as $e2) { $result['trace'][] = (isset($e2['file']) ? $e2['file'] : '(unknown)') . "#" . (isset($e2['line']) ? $e2['line'] : '(unknown)') . ": " . $e2['function'] . (isset($e2['args']) ? format_args_list($e2['args']) : ""); } if ($e->getPrevious()) { $result['cause'] = print_exception_trace_js($e->getPrevious()); } return $result; }