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($e) { if (!$e) { echo "<code>null</code>\n"; return; } if (!$e instanceof Exception) { echo "<i>Not exception: " . get_class($e) . ": " . print_r($e, true) . "</i>"; return; } echo "<ul>"; echo "<li><b>" . htmlspecialchars($e->getMessage()) . "</b> (<i>" . get_class($e) . "</i>)</li>\n"; echo "<li>" . htmlspecialchars($e->getFile()) . "#" . htmlspecialchars($e->getLine()) . "</li>\n"; foreach ($e->getTrace() as $e2) { echo "<li>"; echo isset($e2['file']) ? htmlspecialchars($e2['file']) : "<i>unknown</i>"; echo "#"; echo isset($e2['line']) ? htmlspecialchars($e2['line']) : "<i>unknown</i>"; echo ": " . htmlspecialchars($e2['function']); if (isset($e2['args'])) { echo htmlspecialchars(format_exception_args_list($e2['args'])); } echo "</li>\n"; } if ($e->getPrevious()) { echo "<li>Caused by:"; print_exception_trace($e->getPrevious()); echo "</li>"; } echo "</ul>"; }