Skip to content

Commit b35ca9a

Browse files
eguliasweaverryan
authored andcommitted
- EventListener Exception method error
\Exception does not have a "getCodeStatus" method, but a"getCode". Apart from that, this code is related to the exception not to the Response status code. Therefore I've adapted the $message to have the exception code via getCode and added a 500 HTTP Status Code.
1 parent 37c9aaa commit b35ca9a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cookbook/service_container/event_listener.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ event is just one of the core kernel events::
2626
{
2727
// We get the exception object from the received event
2828
$exception = $event->getException();
29-
$message = 'My Error says: ' . $exception->getMessage();
29+
$message = 'My Error says: ' . $exception->getMessage() . ' with code: ' . $exception->getCode();
3030

3131
// Customize our response object to display our exception details
3232
$response = new Response();
3333
$response->setContent($message);
34-
$response->setStatusCode($exception->getStatusCode());
34+
$response->setStatusCode(500);
3535

3636
// Send our modified response object to the event
3737
$event->setResponse($response);

0 commit comments

Comments
 (0)