mirror of
https://github.com/filp/whoops.git
synced 2026-09-17 13:16:21 +00:00
Add better handling of ErrorException stack traces
This commit is contained in:
+2
-1
@@ -40,7 +40,8 @@ $run->pushHandler(function($exception, $inspector, $run) {
|
||||
$run->register();
|
||||
|
||||
function fooBar() {
|
||||
throw new Exception("Something broke!");
|
||||
// throw new Exception("Something broke!");
|
||||
file("FAIILL");
|
||||
}
|
||||
|
||||
function bar()
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Damnit - php errors for cool kids
|
||||
* @author Filipe Dobreira <http://github.com/filp>
|
||||
*/
|
||||
|
||||
namespace Damnit\Exception;
|
||||
use ErrorException as BaseErrorException;
|
||||
|
||||
/**
|
||||
* Wraps ErrorException; mostly used for typing (at least now)
|
||||
* to easily cleanup the stack trace of redundant info.
|
||||
*/
|
||||
class ErrorException extends BaseErrorException {}
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
namespace Damnit\Exception;
|
||||
use Damnit\Exception\FrameIterator;
|
||||
use Damnit\Exception\ErrorException;
|
||||
use Exception;
|
||||
|
||||
class Inspector
|
||||
@@ -53,9 +54,16 @@ class Inspector
|
||||
{
|
||||
if($this->framesIterator === null) {
|
||||
$frames = $this->exception->getTrace();
|
||||
$firstFrame = $this->getFrameFromException($this->exception);
|
||||
|
||||
array_unshift($frames, $firstFrame);
|
||||
|
||||
// If we're handling an ErrorException thrown by Damnit,
|
||||
// get rid of the last, which matches the handleError method,
|
||||
// and do not add the current exception to trace
|
||||
if($this->exception instanceof ErrorException) {
|
||||
array_shift($frames);
|
||||
} else {
|
||||
$firstFrame = $this->getFrameFromException($this->exception);
|
||||
array_unshift($frames, $firstFrame);
|
||||
}
|
||||
$this->framesIterator = new FrameIterator($frames);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -9,8 +9,8 @@ use Damnit\Handler\HandlerInterface;
|
||||
use Damnit\Handler\Handler;
|
||||
use Damnit\Handler\CallbackHandler;
|
||||
use Damnit\Exception\Inspector;
|
||||
use Damnit\Exception\ErrorException;
|
||||
use InvalidArgumentException;
|
||||
use ErrorException;
|
||||
use Exception;
|
||||
|
||||
class Run
|
||||
|
||||
Reference in New Issue
Block a user