mirror of
https://github.com/filp/whoops.git
synced 2026-09-17 21:26:34 +00:00
Fix #112: pass exception handling on fatal errors properly
This commit is contained in:
+18
-1
@@ -326,7 +326,13 @@ class Run
|
||||
return true;
|
||||
}
|
||||
}
|
||||
throw new ErrorException($message, $level, 0, $file, $line);
|
||||
|
||||
$exception = new ErrorException($message, $level, 0, $file, $line);
|
||||
if ($this->canThrowExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->handleException($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,6 +341,11 @@ class Run
|
||||
*/
|
||||
public function handleShutdown()
|
||||
{
|
||||
// If we reached this step, we are in shutdown handler.
|
||||
// An exception thrown in a shutdown handler will not be propagated
|
||||
// to the exception handler. Pass that information along.
|
||||
$this->canThrowExceptions = false;
|
||||
|
||||
$error = error_get_last();
|
||||
if ($error && $this->isLevelFatal($error['type'])) {
|
||||
$this->handleError(
|
||||
@@ -346,6 +357,12 @@ class Run
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* In certain scenarios, like in shutdown handler, we can not throw exceptions
|
||||
* @var boolean
|
||||
*/
|
||||
private $canThrowExceptions = true;
|
||||
|
||||
private static function isLevelFatal($level)
|
||||
{
|
||||
return in_array(
|
||||
|
||||
Reference in New Issue
Block a user