You are here

public function Js::fatalErrorHandler in JS Callback Handler 8.3

Provides custom PHP fatal error handling.

File

src/Js.php, line 386

Class

Js
JS Callback Handler service.

Namespace

Drupal\js

Code

public function fatalErrorHandler() {
  if ($error = error_get_last()) {
    require_once \Drupal::root() . '/core/includes/errors.inc';
    $error = [
      '%type' => 'Fatal Error',
      // The standard PHP error handler considers that the error messages
      // are HTML. Mimic this behavior here.
      '@message' => Markup::create(Xss::filterAdmin($error['message'])),
      '%file' => $error['file'],
      '%line' => $error['line'],
      'severity_level' => RfcLogLevel::ERROR,
    ];
    $this
      ->logError($error, TRUE);
  }
}