From 838bb1b3ab5908b7fec3bd4e344943e41d26aca0 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 2 Jun 2023 07:53:50 -0500 Subject: [PATCH] Revert "[10.x] Fix inconsistentcy between `report` and `render` methods (#47201)" (#47326) This reverts commit c95df924bd9b87ae8b9804f6fdef2aaad99492f8. --- src/Illuminate/Foundation/Exceptions/Handler.php | 4 ++-- tests/Foundation/FoundationExceptionsHandlerTest.php | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/Illuminate/Foundation/Exceptions/Handler.php b/src/Illuminate/Foundation/Exceptions/Handler.php index 585b3cbe7375..3626d82408d7 100644 --- a/src/Illuminate/Foundation/Exceptions/Handler.php +++ b/src/Illuminate/Foundation/Exceptions/Handler.php @@ -373,8 +373,6 @@ protected function context() */ public function render($request, Throwable $e) { - $e = $this->prepareException($this->mapException($e)); - if (method_exists($e, 'render') && $response = $e->render($request)) { return Router::toResponse($request, $response); } @@ -383,6 +381,8 @@ public function render($request, Throwable $e) return $e->toResponse($request); } + $e = $this->prepareException($this->mapException($e)); + if ($response = $this->renderViaCallbacks($request, $e)) { return $response; } diff --git a/tests/Foundation/FoundationExceptionsHandlerTest.php b/tests/Foundation/FoundationExceptionsHandlerTest.php index 3c1b2d1f0304..12184a6662ab 100644 --- a/tests/Foundation/FoundationExceptionsHandlerTest.php +++ b/tests/Foundation/FoundationExceptionsHandlerTest.php @@ -195,17 +195,6 @@ public function testReturnsCustomResponseWhenExceptionImplementsResponsable() $this->assertSame('{"response":"My responsable exception response"}', $response); } - public function testReturnsCustomResponseFromMappedException() - { - $this->handler->map(function (RuntimeException $e) { - return new ResponsableException(); - }); - - $response = $this->handler->render($this->request, new RuntimeException)->getContent(); - - $this->assertSame('{"response":"My responsable exception response"}', $response); - } - public function testReturnsJsonWithoutStackTraceWhenAjaxRequestAndDebugFalseAndExceptionMessageIsMasked() { $this->config->shouldReceive('get')->with('app.debug', null)->once()->andReturn(false);