Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rethrow non-HTTP exceptions in the test environment (aka functional tester saver)
...
services:
listener.exception_rethrow:
class: App\EventListener\ExceptionRethrowListener
tags:
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException }
<?php
namespace App\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
class ExceptionRethrowListener
{
public function onKernelException(GetResponseForExceptionEvent $event)
{
$exception = $event->getException();
if ($exception instanceof HttpExceptionInterface) {
return;
}
throw $exception;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.