You are here

protected function TestBase::exceptionHandler in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/TestBase.php \Drupal\simpletest\TestBase::exceptionHandler()

Handle exceptions.

See also

set_exception_handler

1 call to TestBase::exceptionHandler()
TestBase::run in core/modules/simpletest/src/TestBase.php
Run all tests in this class.

File

core/modules/simpletest/src/TestBase.php, line 1470
Contains \Drupal\simpletest\TestBase.

Class

TestBase
Base class for Drupal tests.

Namespace

Drupal\simpletest

Code

protected function exceptionHandler($exception) {
  $backtrace = $exception
    ->getTrace();
  $verbose_backtrace = $backtrace;

  // Push on top of the backtrace the call that generated the exception.
  array_unshift($backtrace, array(
    'line' => $exception
      ->getLine(),
    'file' => $exception
      ->getFile(),
  ));
  $decoded_exception = Error::decodeException($exception);
  unset($decoded_exception['backtrace']);
  $message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $decoded_exception + array(
    '@backtrace' => Error::formatBacktrace($verbose_backtrace),
  ));
  $this
    ->error($message, 'Uncaught exception', Error::getLastCaller($backtrace));
}