protected function formatException(\Exception $exception)
    {
        if (!$this->pythonLike) {
            $s = (string) $exception;
            if (substr($s, -1) == "\n") {
                $s = substr($s, 0, -1);
            }
            return $s;
        }

        $s      = "Traceback (most recent call last):\n";
        $traces = array();
        foreach ($exception->getTrace() as $trace) {
            $origin = '';
            if (isset($trace['class'])) {
                $origin = $trace['class'].$trace['type'];
            }
            if (isset($trace['function'])) {
                $origin .= $trace['function'].'()';
            }
            if ($origin == '') {
                $origin = '???';
            }
            $file = isset($trace['file']) ? $trace['file'] : '{main}';
            $line = isset($trace['line']) ? $trace['line'] : 0;
            $traces[] = "File \"$file\", line $line, in $origin";
        }
        $s .= implode("\n", array_reverse($traces))."\n";
        $s .=   "Exception '" . get_class($exception) .
                "' with message '" . $exception->getMessage() .
                "' in " . $exception->getFile() .
                ":" . $exception->getLine();
        return $s;
    }
protected function formatException(\Exception $exception)
    {
        if (!$this->pythonLike) {
            $s = (string) $exception;
            if (substr($s, -1) == "\n") {
                $s = substr($s, 0, -1);
            }
            return $s;
        }

        $s      = "Traceback (most recent call last):\n";
        $traces = array();
        foreach ($exception->getTrace() as $trace) {
            $origin = '';
            if (isset($trace['class'])) {
                $origin = $trace['class'].$trace['type'];
            }
            if (isset($trace['function'])) {
                $origin .= $trace['function'].'()';
            }
            if ($origin == '') {
                $origin = '???';
            }
            $file = isset($trace['file']) ? $trace['file'] : '{main}';
            $line = isset($trace['line']) ? $trace['line'] : 0;
            $traces[] = "File \"$file\", line $line, in $origin";
        }
        $s .= implode("\n", array_reverse($traces))."\n";
        $s .=   "Exception '" . get_class($exception) .
                "' with message '" . $exception->getMessage() .
                "' in " . $exception->getFile() .
                ":" . $exception->getLine();
        return $s;
    }
protected function formatException ( \ Exception $ exception ) { if ( ! $ this -> pythonLike ) { $ s = ( string ) $ exception ; if ( substr ( $ s , - 1 ) == "\n" ) { $ s = substr ( $ s , 0 , - 1 ) ; } return $ s ; } $ s = "Traceback (most recent call last):\n" ; $ traces = array ( ) ; foreach ( $ exception -> getTrace ( ) as $ trace ) { $ origin = '' ; if ( isset ( $ trace [ 'class' ] ) ) { $ origin = $ trace [ 'class' ] . $ trace [ 'type' ] ; } if ( isset ( $ trace [ 'function' ] ) ) { $ origin .= $ trace [ 'function' ] . '()' ; } if ( $ origin == '' ) { $ origin = '???' ; } $ file = isset ( $ trace [ 'file' ] ) ? $ trace [ 'file' ] : '{main}' ; $ line = isset ( $ trace [ 'line' ] ) ? $ trace [ 'line' ] : 0 ; $ traces [ ] = "File \"$file\", line $line, in $origin" ; } $ s .= implode ( "\n" , array_reverse ( $ traces ) ) . "\n" ; $ s .= "Exception '" . get_class ( $ exception ) . "' with message '" . $ exception -> getMessage ( ) . "' in " . $ exception -> getFile ( ) . ":" . $ exception -> getLine ( ) ; return $ s ; }
Format an exception.

\param ::Exception $exception
The exception to format.

\retval string
The full trace of the exception, with proper formatting
or \a false if the current PHP settings prevent errors
from being displayed.
Format an exception .