public static function FlattenException::create

14 calls to FlattenException::create()
ExceptionControllerTest::test405HTML in drupal/core/modules/system/lib/Drupal/system/Tests/System/ExceptionControllerTest.php
Ensure the execute() method returns a valid response on 405 exceptions.
ExceptionDataCollector::collect in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php
Collects data for the given Request and Response.
ExceptionDataCollectorTest::testCollect in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php
ExceptionHandler::createResponse in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php
Creates the error Response associated with the given Exception.
ExceptionListener::onKernelException in drupal/core/lib/Drupal/Core/EventSubscriber/ExceptionListener.php

... See full list

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php, line 33

Class

FlattenException
FlattenException wraps a PHP Exception to be able to serialize it.

Namespace

Symfony\Component\HttpKernel\Exception

Code

public static function create(\Exception $exception, $statusCode = null, array $headers = array()) {
  $e = new static();
  $e
    ->setMessage($exception
    ->getMessage());
  $e
    ->setCode($exception
    ->getCode());
  if ($exception instanceof HttpExceptionInterface) {
    $statusCode = $exception
      ->getStatusCode();
    $headers = array_merge($headers, $exception
      ->getHeaders());
  }
  if (null === $statusCode) {
    $statusCode = 500;
  }
  $e
    ->setStatusCode($statusCode);
  $e
    ->setHeaders($headers);
  $e
    ->setTrace($exception
    ->getTrace(), $exception
    ->getFile(), $exception
    ->getLine());
  $e
    ->setClass(get_class($exception));
  $e
    ->setFile($exception
    ->getFile());
  $e
    ->setLine($exception
    ->getLine());
  if ($exception
    ->getPrevious()) {
    $e
      ->setPrevious(static::create($exception
      ->getPrevious()));
  }
  return $e;
}