8000 [HttpKernel] Provide status code in fragment handler exception · symfony/symfony@c966456 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit c966456

Browse files
[HttpKernel] Provide status code in fragment handler exception
1 parent be81e3d commit c966456

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public function render($uri, string $renderer = 'inline', array $options = [])
9797
protected function deliver(Response $response)
9898
{
9999
if (!$response->isSuccessful()) {
100-
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode()));
100+
$responseStatusCode = $response->getStatusCode();
101+
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $responseStatusCode), $responseStatusCode);
101102
}
102103

103104
if (!$response instanceof StreamedResponse) {

src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function testDeliverWithUnsuccessfulResponse()
5555
{
5656
$this->expectException('RuntimeException');
5757
$this->expectExceptionMessage('Error when rendering "http://localhost/" (Status code is 404).');
58+
$this->expectExceptionCode(404);
5859
$handler = $this->getHandler($this->returnValue(new Response('foo', 404)));
5960

6061
$handler->render('/', 'foo');

0 commit comments

Comments
 (0)
0