You are here

protected function DrupalKernel::handleException in Zircon Profile 8

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

Converts an exception into a response.

Parameters

\Exception $e: An exception

Request $request: A Request instance

int $type: The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)

Return value

Response A Response instance

Throws

\Exception If the passed in exception cannot be turned into a response.

2 calls to DrupalKernel::handleException()
DrupalKernel::handle in core/lib/Drupal/Core/DrupalKernel.php
Handles a Request to convert it to a Response.
UpdateKernel::handle in core/lib/Drupal/Core/Update/UpdateKernel.php
Handles a Request to convert it to a Response.

File

core/lib/Drupal/Core/DrupalKernel.php, line 671
Contains \Drupal\Core\DrupalKernel.

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

protected function handleException(\Exception $e, $request, $type) {
  if ($e instanceof HttpExceptionInterface) {
    $response = new Response($e
      ->getMessage(), $e
      ->getStatusCode());
    $response->headers
      ->add($e
      ->getHeaders());
    return $response;
  }
  else {
    throw $e;
  }
}