Skip to content

Commit 78d576e

Browse files
committed
HTTP error code is not correctly fetched from exception code
The HTTP code of the error page is not correctly fetched from the exception code. This PR starts with a failing test. See #17
1 parent b8a1896 commit 78d576e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Tests/Fixtures/Controller/TestGraphqlController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public function contacts(): ArrayResult
6161
* @Query()
6262
* @return string
6363
*/
64-
public function triggerError(): string
64+
public function triggerError(int $code = 500): string
6565
{
66-
throw new MyException('Boom');
66+
throw new MyException('Boom', $code);
6767
}
6868
}

Tests/FunctionalTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,13 @@ public function testErrors()
113113

114114
$this->assertSame(500, $response->getStatusCode());
115115

116+
$request = Request::create('/graphql', 'GET', ['query' => '
117+
{
118+
triggerError(code: 404)
119+
}']);
120+
121+
$response = $kernel->handle($request);
122+
123+
$this->assertSame(404, $response->getStatusCode(), $response->getContent());
116124
}
117125
}

0 commit comments

Comments
 (0)