コード例 #1
0
 public static function format(\Exception $exception, $htmlMode = false)
 {
     $result = '[' . get_class($exception) . '] ';
     if ($exception instanceof \ErrorException) {
         $result .= static::severityToString($exception->getSeverity());
     }
     $result .= "\n" . static::getMessage($exception) . "\n";
     $fileLink = static::getFileLink($exception->getFile(), $exception->getLine());
     $result .= $fileLink . (empty($fileLink) ? "" : "\n");
     if ($htmlMode) {
         $result = Main\Text\String::htmlspecialchars($result);
     }
     $prevArg = null;
     $trace = static::getTrace($exception);
     foreach ($trace as $traceNum => $traceInfo) {
         $traceLine = '#' . $traceNum . ': ';
         if (array_key_exists('class', $traceInfo)) {
             $traceLine .= $traceInfo['class'] . $traceInfo['type'];
         }
         if (array_key_exists('function', $traceInfo)) {
             $traceLine .= $traceInfo['function'];
             $traceLine .= static::getArguments($traceInfo['args']);
         }
         if ($htmlMode) {
             $traceLine = Main\Text\String::htmlspecialchars($traceLine);
         }
         if (array_key_exists('file', $traceInfo)) {
             $traceLine .= "\n\t" . static::getFileLink($traceInfo['file'], $traceInfo['line']);
         } else {
             $traceLine .= "\n\t" . static::getFileLink(null, null);
         }
         $result .= $traceLine . "\n";
     }
     if ($htmlMode) {
         $result = '<pre>' . $result . '</pre>';
     }
     return $result;
 }