Perforce Chronicle 2012.2/486814
API Documentation
|
View helper that displays stack traces without the source file. More...
Public Member Functions | |
stackTrace ($e) | |
Format and return a stack trace for the given exception. |
View helper that displays stack traces without the source file.
Error_View_Helper_StackTrace::stackTrace | ( | $ | e | ) |
Format and return a stack trace for the given exception.
Excludes source file information and lines up numbers.
Exception | $e | the exception to produce a trace for. |
{ $entries = explode("\n", $e->getTraceAsString()); $output = ""; foreach ($entries as $entry) { preg_match("/\#([0-9]+) ([^:\(]+)(?:\(([0-9]+)\))?(?:\: )?(.*)/", $entry, $matches); $depth = isset($matches[1]) ? $matches[1] : null; $line = isset($matches[3]) && $matches[3] ? "(" . $matches[3] . ")" : null; $call = isset($matches[4]) ? $matches[4] : null; // skip entries without call information (e.g. '{main}'). if (!$call) { continue; } $output .= str_pad($this->view->escape($depth), 3, ' ', STR_PAD_LEFT) . ": "; $output .= str_pad($this->view->escape($line), 5, ' ', STR_PAD_LEFT) . " "; $output .= $this->view->escape($call); $output .= "\n"; } return $output; }