Skip to content

Commit

Permalink
Fix exception handling (#21086)
Browse files Browse the repository at this point in the history
  • Loading branch information
sileence authored and taylorotwell committed Sep 8, 2017
1 parent 2dc3da1 commit e2b48c0
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
trait InteractsWithExceptionHandling
{
/**
* The previous exception handler.
* The original exception handler.
*
* @var ExceptionHandler|null
*/
protected $previousExceptionHandler;
protected $originalExceptionHandler;

/**
* Restore exception handling.
Expand All @@ -24,8 +24,8 @@ trait InteractsWithExceptionHandling
*/
protected function withExceptionHandling()
{
if ($this->previousExceptionHandler) {
$this->app->instance(ExceptionHandler::class, $this->previousExceptionHandler);
if ($this->originalExceptionHandler) {
$this->app->instance(ExceptionHandler::class, $this->originalExceptionHandler);
}

return $this;
Expand Down Expand Up @@ -60,11 +60,13 @@ protected function handleValidationExceptions()
*/
protected function withoutExceptionHandling(array $except = [])
{
$this->previousExceptionHandler = app(ExceptionHandler::class);
if ($this->originalExceptionHandler == null) {
$this->originalExceptionHandler = app(ExceptionHandler::class);
}

$this->app->instance(ExceptionHandler::class, new class($this->previousExceptionHandler, $except) implements ExceptionHandler {
$this->app->instance(ExceptionHandler::class, new class($this->originalExceptionHandler, $except) implements ExceptionHandler {
protected $except;
protected $previousHandler;
protected $originalHandler;

/**
* Create a new class instance.
Expand All @@ -73,10 +75,10 @@ protected function withoutExceptionHandling(array $except = [])
* @param array $except
* @return void
*/
public function __construct($previousHandler, $except = [])
public function __construct($originalHandler, $except = [])
{
$this->except = $except;
$this->previousHandler = $previousHandler;
$this->originalHandler = $originalHandler;
}

/**
Expand Down Expand Up @@ -109,7 +111,7 @@ public function render($request, Exception $e)

foreach ($this->except as $class) {
if ($e instanceof $class) {
return $this->previousHandler->render($request, $e);
return $this->originalHandler->render($request, $e);
}
}

Expand Down

0 comments on commit e2b48c0

Please sign in to comment.