Error::renderExceptionSafe

public static Error::renderExceptionSafe($exception)

Renders an exception error message without further exceptions.

Parameters

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

Return value

string An error message.

File

core/lib/Drupal/Core/Utility/Error.php, line 87

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);
}
doc_Drupal
2016-10-29 09:09:19
Comments
Leave a Comment

Please login to continue.