|
@@ -48,10 +48,14 @@ class ExceptionListener
|
|
|
|
|
|
public function handle(Event $event)
|
|
public function handle(Event $event)
|
|
{
|
|
{
|
|
- if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type')) {
|
|
|
|
|
|
+ static $handling;
|
|
|
|
+
|
|
|
|
+ if (true === $handling) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ $handling = true;
|
|
|
|
+
|
|
$exception = $event->get('exception');
|
|
$exception = $event->get('exception');
|
|
$request = $event->get('request');
|
|
$request = $event->get('request');
|
|
|
|
|
|
@@ -76,16 +80,21 @@ class ExceptionListener
|
|
try {
|
|
try {
|
|
$response = $event->getSubject()->handle($request, HttpKernelInterface::SUB_REQUEST, true);
|
|
$response = $event->getSubject()->handle($request, HttpKernelInterface::SUB_REQUEST, true);
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
|
+ $message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
|
|
if (null !== $this->logger) {
|
|
if (null !== $this->logger) {
|
|
- $this->logger->err(sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()));
|
|
|
|
|
|
+ $this->logger->err($message);
|
|
|
|
+ } else {
|
|
|
|
+ error_log($message);
|
|
}
|
|
}
|
|
|
|
|
|
// re-throw the exception as this is a catch-all
|
|
// re-throw the exception as this is a catch-all
|
|
- throw new \RuntimeException('Exception thrown when handling an exception.', 0, $e);
|
|
|
|
|
|
+ throw $exception;
|
|
}
|
|
}
|
|
|
|
|
|
$event->setReturnValue($response);
|
|
$event->setReturnValue($response);
|
|
|
|
|
|
|
|
+ $handling = false;
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|