public function onException(ExceptionEvent
$event) { $exception =
$event->
getThrowable();
// Make the exception available for example when rendering a block.
$request =
$event->
getRequest();
$request->attributes->
set('exception',
$exception);
$handled_formats =
$this->
getHandledFormats();
$format =
$request->query->
get(MainContentViewSubscriber::WRAPPER_FORMAT,
$request->
getRequestFormat());
if ($exception instanceof HttpExceptionInterface
&& (empty($handled_formats) ||
in_array($format,
$handled_formats))) { $method = 'on' .
$exception->
getStatusCode();
// Keep just the leading number of the status code to produce either a
// 400 or a 500 method callback.
$method_fallback = 'on' .
substr($exception->
getStatusCode(), 0, 1
) . 'xx';
// We want to allow the method to be called and still not set a response
// if it has additional filtering logic to determine when it will apply.
// It is therefore the method's responsibility to set the response on the