Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DefaultExceptionSubscriber.php

function DefaultExceptionSubscriber::onException

Overrides HttpExceptionSubscriberBase::onException

File

core/modules/jsonapi/src/EventSubscriber/DefaultExceptionSubscriber.php, line 44

Class

DefaultExceptionSubscriber
Serializes exceptions in compliance with the JSON:API specification.

Namespace

Drupal\jsonapi\EventSubscriber

Code

public function onException(ExceptionEvent $event) {
    if (!$this->isJsonApiExceptionEvent($event)) {
        return;
    }
    if (($exception = $event->getThrowable()) && !$exception instanceof HttpException) {
        $exception = new HttpException(500, $exception->getMessage(), $exception);
        $event->setThrowable($exception);
    }
    $this->setEventResponse($event, $exception->getStatusCode());
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal