EnforcedResponse::createFromException

public static EnforcedResponse::createFromException(\Exception $e)

Constructs a new enforced response from the given exception.

Note that it is necessary to traverse the exception chain when searching for an enforced response. Otherwise it would be impossible to find an exception thrown from within a twig template.

Parameters

\Exception $e: The exception where the enforced response is to be extracted from.

Return value

\Drupal\Core\Form\EnforcedResponse|null The enforced response or NULL if the exception chain does not contain a \Drupal\Core\Form\EnforcedResponseException exception.

File

core/lib/Drupal/Core/Form/EnforcedResponse.php, line 44

Class

EnforcedResponse
A wrapper containing a response which is to be enforced upon delivery.

Namespace

Drupal\Core\Form

Code

public static function createFromException(\Exception $e) {
  while ($e) {
    if ($e instanceof EnforcedResponseException) {
      return new static($e->getResponse());
    }

    $e = $e->getPrevious();
  }
}
doc_Drupal
2016-10-29 09:04:09
Comments
Leave a Comment

Please login to continue.