isJsonApiExceptionEvent example

/** * {@inheritdoc} */
  protected function getHandledFormats() {
    return ['api_json'];
  }

  /** * {@inheritdoc} */
  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());
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.