W3cubDocs

/Drupal 8

protected function DrupalKernel::handleException

protected DrupalKernel::handleException(\Exception $e, $request, $type)

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.

File

core/lib/Drupal/Core/DrupalKernel.php, line 662

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;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!DrupalKernel.php/function/DrupalKernel::handleException/8.1.x