You are here

protected function TestBase::exceptionHandler in SimpleTest 8.3

Handle exceptions.

See also

set_exception_handler

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

File

src/TestBase.php, line 1337

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, [
    'line' => $exception
      ->getLine(),
    'file' => $exception
      ->getFile(),
  ]);
  $decoded_exception = Error::decodeException($exception);
  unset($decoded_exception['backtrace']);
  $message = new FormattableMarkup('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $decoded_exception + [
    '@backtrace' => Error::formatBacktrace($verbose_backtrace),
  ]);
  $this
    ->error($message, 'Uncaught exception', Error::getLastCaller($backtrace));
}