diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php index dc4bf00..d80384c 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php @@ -3,7 +3,6 @@ namespace Drupal\Core\EventSubscriber; use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; /** @@ -28,12 +27,12 @@ protected static function getPriority() { } /** - * Handles all 400 errors for JSON. + * Handles all 4xx errors for JSON. * * @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event * The event to process. */ - public function on400(GetResponseForExceptionEvent $event) { + public function on4xx(GetResponseForExceptionEvent $event) { /** @var \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $exception */ $exception = $event->getException(); $response = new JsonResponse(['message' => $event->getException()->getMessage()], $exception->getStatusCode()); diff --git a/core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php b/core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php index 84fe421..b062b97 100644 --- a/core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php +++ b/core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php @@ -92,7 +92,7 @@ public function onException(GetResponseForExceptionEvent $event) { $method = 'on' . $exception->getStatusCode(); // Keep just the leading number of the status code to produce either a // on400 or a 500 method callback. - $method_fallback = 'on' . floor($exception->getStatusCode() / 100) . '00'; + $method_fallback = 'on' . floor($exception->getStatusCode() / 100) . '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