Perforce Chronicle 2012.2/486814
API Documentation

Error_View_Helper_StackTrace Class Reference

View helper that displays stack traces without the source file. More...

List of all members.

Public Member Functions

 stackTrace ($e)
 Format and return a stack trace for the given exception.

Detailed Description

View helper that displays stack traces without the source file.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

Error_View_Helper_StackTrace::stackTrace ( e)

Format and return a stack trace for the given exception.

Excludes source file information and lines up numbers.

Parameters:
Exception$ethe exception to produce a trace for.
Returns:
string html presentation of the stack trace.
    {
        $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;
    }

The documentation for this class was generated from the following file: