You are here

protected function ExecuteInRenderContextTrait::handleExceptionInRenderContext in SAML Authentication 8.3

Same name and namespace in other branches
  1. 4.x src/Controller/ExecuteInRenderContextTrait.php \Drupal\samlauth\Controller\ExecuteInRenderContextTrait::handleExceptionInRenderContext()

Displays and/or logs exception message if the wrapped callable fails.

Only called by getTrustedRedirectResponse() so far. Can be overridden to implement other ways of logging and redirect to other paths. (Yes, those are two separate functions that are just stuck together for convenient overriding...)

Parameters

\Exception $exception: The exception thrown.

string $default_redirect_route: The route to redirect to, by default.

string $while: (Optional) description of when the error was encountered.

Return value

\Drupal\Core\Url|string URL to redirect to.

1 call to ExecuteInRenderContextTrait::handleExceptionInRenderContext()
ExecuteInRenderContextTrait::getTrustedRedirectResponse in src/Controller/ExecuteInRenderContextTrait.php
Executes code in a render context; generates a TrustedRedirectResponse.
1 method overrides ExecuteInRenderContextTrait::handleExceptionInRenderContext()
SamlController::handleExceptionInRenderContext in src/Controller/SamlController.php
@todo in 4.x, always throw; move our own error handling into AccessDeniedSubscriber. This means the situation of error_throw=TRUE will become standard. It would be nice to first do some investigation if contrib modules doing error redirection…

File

src/Controller/ExecuteInRenderContextTrait.php, line 257

Class

ExecuteInRenderContextTrait
Helper code for executing a callable inside a render context.

Namespace

Drupal\samlauth\Controller

Code

protected function handleExceptionInRenderContext(\Exception $exception, $default_redirect_route, $while = '') {
  if (isset($this->logger)) {
    $this->logger
      ->error($exception
      ->getMessage());
  }
  if (isset($this->messenger)) {
    $this->messenger
      ->addError($exception
      ->getMessage());
  }
  return Url::fromRoute($default_redirect_route);
}