Skip to content

Commit 38b353e

Browse files
committed
Tweak the exception handler so status codes are only set on new responses.
Signed-off-by: Jason Lewis <[email protected]>
1 parent ea85757 commit 38b353e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/ExceptionHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public function handle(HttpExceptionInterface $exception)
4343

4444
if ( ! $response instanceof Response)
4545
{
46-
$response = new Response($response);
46+
$response = new Response($response, $exception->getStatusCode());
4747
}
4848

49-
return $response->setStatusCode($exception->getStatusCode());
49+
return $response;
5050
}
5151
}
5252
}
@@ -95,4 +95,4 @@ public function getHandlers()
9595
return $this->handlers;
9696
}
9797

98-
}
98+
}

tests/ExceptionHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testExceptionHandlerHandlesException()
3535
{
3636
$this->exceptionHandler->register(function(StubHttpException $e)
3737
{
38-
return new Illuminate\Http\Response('foo');
38+
return new Illuminate\Http\Response('foo', 404);
3939
});
4040

4141
$response = $this->exceptionHandler->handle(new StubHttpException(404, 'bar'));
@@ -60,4 +60,4 @@ public function testExceptionHandlerHandlesExceptionAndCreatesNewResponse()
6060
}
6161

6262

63-
}
63+
}

0 commit comments

Comments
 (0)