forked from igorsantos07/yii-whoops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
YiiWhoopsInspector.php
47 lines (41 loc) · 1.27 KB
/
YiiWhoopsInspector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
use Whoops\Exception\FrameCollection;
class YiiWhoopsInspector extends \Whoops\Exception\Inspector
{
/**
* @var \Whoops\Exception\FrameCollection
*/
private $frames;
/**
* Override default implementation for two reasons:
* ErrorException is caught by WhoopsErrorHandler, so it will
* have a line and would be displayed by Whoops.
* The default behavior of Whoops in case of an ErrorException
* without a line is to only display one frame, we instead display
* a full stack trace up to the actual error.
* The stack trace is cut off at CApplication::handleError.
* @return \Whoops\Exception\FrameCollection
*/
public function getFrames()
{
if($this->frames === null) {
$exception = $this->getException();
if (!$exception instanceof \Whoops\Exception\ErrorException) {
$this->frames = parent::getFrames();
return $this->frames;
}
$frames = $exception->getTrace();
foreach ($frames as $i => $frame) {
unset($frames[$i]);
if ($frame['class'] === 'CApplication' && $frame['function'] === 'handleError') {
break;
}
}
$frames = array_values($frames);
$this->frames = new FrameCollection($frames);
// ErrorException doesn't have previous exception,
// skip adding its frames
}
return $this->frames;
}
}