You are here

public static function Error::renderExceptionSafe in Zircon Profile 8

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

Renders an exception error message without further exceptions.

Parameters

\Exception|\Throwable $exception: The exception object that was thrown.

Return value

string An error message.

3 calls to Error::renderExceptionSafe()
SessionHandler::write in core/lib/Drupal/Core/Session/SessionHandler.php
_drupal_exception_handler_additional in core/includes/bootstrap.inc
Displays any additional errors caught while handling an exception.
_drupal_shutdown_function_handle_exception in core/includes/bootstrap.inc
Displays and logs any errors that may happen during shutdown.

File

core/lib/Drupal/Core/Utility/Error.php, line 91
Contains \Drupal\Core\Utility\Error.

Class

Error
Drupal error utility class.

Namespace

Drupal\Core\Utility

Code

public static function renderExceptionSafe($exception) {
  $decode = static::decodeException($exception);
  $backtrace = $decode['backtrace'];
  unset($decode['backtrace']);

  // Remove 'main()'.
  array_shift($backtrace);

  // Even though it is possible that this method is called on a public-facing
  // site, it is only called when the exception handler itself threw an
  // exception, which normally means that a code change caused the system to
  // no longer function correctly (as opposed to a user-triggered error), so
  // we assume that it is safe to include a verbose backtrace.
  $decode['@backtrace'] = Error::formatBacktrace($backtrace);
  return SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $decode);
}