Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Fix exception handling #21086

Merged
merged 1 commit into from
Sep 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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