Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e257545

Browse filesBrowse files
coderbyheartweaverryan
authored andcommitted
Fixed the example code for creating an exception listener: the $response was never initialized.
1 parent ce7beac commit e257545
Copy full SHA for e257545

File tree

Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed

‎cookbook/service_container/event_listener.rst

Copy file name to clipboardExpand all lines: cookbook/service_container/event_listener.rst
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ event is just one of the core kernel events::
1717
// src/Acme/DemoBundle/Listener/AcmeExceptionListener.php
1818
namespace Acme\DemoBundle\Listener;
1919

20-
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
20+
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent,
21+
Symfony\Component\HttpFoundation\Response;
2122

2223
class AcmeExceptionListener
2324
{
@@ -28,6 +29,7 @@ event is just one of the core kernel events::
2829
$message = 'My Error says: ' . $exception->getMessage();
2930
3031
// Customize our response object to display our exception details
32+
$response = new Response();
3133
$response->setContent($message);
3234
$response->setStatusCode($exception->getStatusCode());
3335

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.