You are here

public function ExceptionJsonSubscriber::on406 in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php \Drupal\Core\EventSubscriber\ExceptionJsonSubscriber::on406()

Handles a 406 error for JSON.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event: The event to process.

File

core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php, line 74
Contains \Drupal\Core\EventSubscriber\ExceptionJsonSubscriber.

Class

ExceptionJsonSubscriber
Default handling for JSON errors.

Namespace

Drupal\Core\EventSubscriber

Code

public function on406(GetResponseForExceptionEvent $event) {
  $response = new JsonResponse([
    'message' => $event
      ->getException()
      ->getMessage(),
  ], Response::HTTP_NOT_ACCEPTABLE);
  $event
    ->setResponse($response);
}