Skip to content

Commit 927bafb

Browse files
[HttpKernel] Provide status code in fragment handler exception
1 parent 812a4d5 commit 927bafb

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ 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+
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode()), $response->getStatusCode());
101101
}
102102

103103
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy