ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Formatter.php
Go to the documentation of this file.
1<?php
7namespace Whoops\Exception;
8
9
11{
19 public static function formatExceptionAsDataArray(Inspector $inspector, $shouldAddTrace)
20 {
21 $exception = $inspector->getException();
22 $response = array(
23 'type' => get_class($exception),
24 'message' => $exception->getMessage(),
25 'file' => $exception->getFile(),
26 'line' => $exception->getLine(),
27 );
28
29 if ($shouldAddTrace) {
30 $frames = $inspector->getFrames();
31 $frameData = array();
32
33 foreach ($frames as $frame) {
35 $frameData[] = array(
36 'file' => $frame->getFile(),
37 'line' => $frame->getLine(),
38 'function' => $frame->getFunction(),
39 'class' => $frame->getClass(),
40 'args' => $frame->getArgs(),
41 );
42 }
43
44 $response['trace'] = $frameData;
45 }
46
47 return $response;
48 }
49
50 public static function formatExceptionPlain(Inspector $inspector)
51 {
52 $message = $inspector->getException()->getMessage();
53 $frames = $inspector->getFrames();
54
55 $plain = $inspector->getExceptionName();
56 $plain .= ' thrown with message "';
57 $plain .= $message;
58 $plain .= '"'."\n\n";
59
60 $plain .= "Stacktrace:\n";
61 foreach ($frames as $i => $frame) {
62 $plain .= "#". (count($frames) - $i - 1). " ";
63 $plain .= $frame->getClass() ?: '';
64 $plain .= $frame->getClass() && $frame->getFunction() ? ":" : "";
65 $plain .= $frame->getFunction() ?: '';
66 $plain .= ' in ';
67 $plain .= ($frame->getFile() ?: '<#unknown>');
68 $plain .= ':';
69 $plain .= (int) $frame->getLine(). "\n";
70 }
71
72 return $plain;
73 }
74}
static formatExceptionPlain(Inspector $inspector)
Definition: Formatter.php:50
getFrames()
Returns an iterator for the inspected exception's frames.
Definition: Inspector.php:92
Whoops - php errors for cool kids.