ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Whoops\Exception\Inspector Class Reference
+ Collaboration diagram for Whoops\Exception\Inspector:

Public Member Functions

 __construct (Exception $exception)
 
 getException ()
 
 getExceptionName ()
 
 getExceptionMessage ()
 
 hasPreviousException ()
 Does the wrapped Exception has a previous Exception? More...
 
 getPreviousExceptionInspector ()
 Returns an Inspector for a previous Exception, if any. More...
 
 getFrames ()
 Returns an iterator for the inspected exception's frames. More...
 

Protected Member Functions

 getFrameFromException (Exception $exception)
 Given an exception, generates an array in the format generated by Exception::getTrace() More...
 
 getFrameFromError (ErrorException $exception)
 Given an error, generates an array in the format generated by ErrorException. More...
 

Private Attributes

 $exception
 
 $frames
 
 $previousExceptionInspector
 

Detailed Description

Definition at line 11 of file Inspector.php.

Constructor & Destructor Documentation

◆ __construct()

Whoops\Exception\Inspector::__construct ( Exception  $exception)
Parameters
Exception$exceptionThe exception to inspect

Definition at line 31 of file Inspector.php.

32 {
33 $this->exception = $exception;
34 }

References Whoops\Exception\Inspector\$exception.

Member Function Documentation

◆ getException()

Whoops\Exception\Inspector::getException ( )
Returns
Exception

Definition at line 39 of file Inspector.php.

40 {
41 return $this->exception;
42 }

References Whoops\Exception\Inspector\$exception.

Referenced by Whoops\Exception\Formatter\formatExceptionPlain().

+ Here is the caller graph for this function:

◆ getExceptionMessage()

Whoops\Exception\Inspector::getExceptionMessage ( )
Returns
string

Definition at line 55 of file Inspector.php.

56 {
57 return $this->exception->getMessage();
58 }

◆ getExceptionName()

Whoops\Exception\Inspector::getExceptionName ( )
Returns
string

Definition at line 47 of file Inspector.php.

48 {
49 return get_class($this->exception);
50 }

Referenced by Whoops\Exception\Formatter\formatExceptionPlain().

+ Here is the caller graph for this function:

◆ getFrameFromError()

Whoops\Exception\Inspector::getFrameFromError ( ErrorException  $exception)
protected

Given an error, generates an array in the format generated by ErrorException.

Parameters
ErrorException$exception
Returns
array

Definition at line 152 of file Inspector.php.

153 {
154 return array(
155 'file' => $exception->getFile(),
156 'line' => $exception->getLine(),
157 'class' => null,
158 'args' => array(),
159 );
160 }

References Whoops\Exception\Inspector\$exception.

Referenced by Whoops\Exception\Inspector\getFrames().

+ Here is the caller graph for this function:

◆ getFrameFromException()

Whoops\Exception\Inspector::getFrameFromException ( Exception  $exception)
protected

Given an exception, generates an array in the format generated by Exception::getTrace()

Parameters
Exception$exception
Returns
array

Definition at line 134 of file Inspector.php.

135 {
136 return array(
137 'file' => $exception->getFile(),
138 'line' => $exception->getLine(),
139 'class' => get_class($exception),
140 'args' => array(
141 $exception->getMessage(),
142 ),
143 );
144 }

References Whoops\Exception\Inspector\$exception.

Referenced by Whoops\Exception\Inspector\getFrames().

+ Here is the caller graph for this function:

◆ getFrames()

Whoops\Exception\Inspector::getFrames ( )

Returns an iterator for the inspected exception's frames.

Returns
\Whoops\Exception\FrameCollection

Definition at line 92 of file Inspector.php.

93 {
94 if ($this->frames === null) {
95 $frames = $this->exception->getTrace();
96
97 // If we're handling an ErrorException thrown by Whoops,
98 // get rid of the last frame, which matches the handleError method,
99 // and do not add the current exception to trace. We ensure that
100 // the next frame does have a filename / linenumber, though.
101 if ($this->exception instanceof ErrorException && empty($frames[1]['line'])) {
102 $frames = array($this->getFrameFromError($this->exception));
103 } else {
104 $firstFrame = $this->getFrameFromException($this->exception);
105 array_unshift($frames, $firstFrame);
106 }
107 $this->frames = new FrameCollection($frames);
108
109 if ($previousInspector = $this->getPreviousExceptionInspector()) {
110 // Keep outer frame on top of the inner one
111 $outerFrames = $this->frames;
112 $newFrames = clone $previousInspector->getFrames();
113 // I assume it will always be set, but let's be safe
114 if (isset($newFrames[0])) {
115 $newFrames[0]->addComment(
116 $previousInspector->getExceptionMessage(),
117 'Exception message:'
118 );
119 }
120 $newFrames->prependFrames($outerFrames->topDiff($newFrames));
121 $this->frames = $newFrames;
122 }
123 }
124
125 return $this->frames;
126 }
Wraps ErrorException; mostly used for typing (at least now) to easily cleanup the stack trace of redu...
getFrameFromError(ErrorException $exception)
Given an error, generates an array in the format generated by ErrorException.
Definition: Inspector.php:152
getPreviousExceptionInspector()
Returns an Inspector for a previous Exception, if any.
Definition: Inspector.php:74
getFrameFromException(Exception $exception)
Given an exception, generates an array in the format generated by Exception::getTrace()
Definition: Inspector.php:134

References Whoops\Exception\Inspector\$frames, Whoops\Exception\Inspector\getFrameFromError(), Whoops\Exception\Inspector\getFrameFromException(), and Whoops\Exception\Inspector\getPreviousExceptionInspector().

Referenced by Whoops\Exception\Formatter\formatExceptionPlain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPreviousExceptionInspector()

Whoops\Exception\Inspector::getPreviousExceptionInspector ( )

Returns an Inspector for a previous Exception, if any.

Todo:
Clean this up a bit, cache stuff a bit better.
Returns
Inspector

Definition at line 74 of file Inspector.php.

75 {
76 if ($this->previousExceptionInspector === null) {
77 $previousException = $this->exception->getPrevious();
78
79 if ($previousException) {
80 $this->previousExceptionInspector = new Inspector($previousException);
81 }
82 }
83
85 }

References Whoops\Exception\Inspector\$previousExceptionInspector.

Referenced by Whoops\Exception\Inspector\getFrames().

+ Here is the caller graph for this function:

◆ hasPreviousException()

Whoops\Exception\Inspector::hasPreviousException ( )

Does the wrapped Exception has a previous Exception?

Returns
bool

Definition at line 64 of file Inspector.php.

65 {
66 return $this->previousExceptionInspector || $this->exception->getPrevious();
67 }

Field Documentation

◆ $exception

◆ $frames

Whoops\Exception\Inspector::$frames
private

Definition at line 21 of file Inspector.php.

Referenced by Whoops\Exception\Inspector\getFrames().

◆ $previousExceptionInspector

Whoops\Exception\Inspector::$previousExceptionInspector
private

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