function backtrace_error_handler
Displays backtrace showing the route of calls to the current error.
Parameters
int $error_level: The level of the error raised.
string $message: The error message.
string|null $filename: (optional) The filename that the error was raised in.
int $line: (optional) The line number the error was raised at.
array $context: (optional) An array that points to the active symbol table at the point the error occurred.
2 string references to 'backtrace_error_handler'
- DevelDumperBase::getInternalFunctions in src/DevelDumperBase.php 
- Returns a list of internal functions.
- devel_set_handler in ./devel.module 
- Sets a new error handler or restores the prior one.
File
- 
              ./devel.module, line 188 
Code
function backtrace_error_handler($error_level, $message, ?string $filename = NULL, $line = NULL, ?array $context = NULL) {
  // Hide stack trace and parameters from unqualified users.
  if (!Drupal::currentUser()->hasPermission('access devel information')) {
    // Do what core does in bootstrap.inc and errors.inc.
    // (We need to duplicate the core code here rather than calling it
    // to avoid having the backtrace_error_handler() on top of the call stack.)
    if ($error_level & error_reporting()) {
      $types = drupal_error_levels();
      [$severity_msg, $severity_level] = $types[$error_level];
      $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
      $caller = Error::getLastCaller($backtrace);
      // We treat recoverable errors as fatal.
      _drupal_log_error([
        '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
        '@message' => $message,
        '%function' => $caller['function'],
        '%file' => $caller['file'],
        '%line' => $caller['line'],
        'severity_level' => $severity_level,
        'backtrace' => $backtrace,
      ], $error_level == E_RECOVERABLE_ERROR);
    }
    return;
  }
  // Don't respond to the error if it was suppressed with a '@'.
  if (error_reporting() == 0) {
    return;
  }
  // Don't respond to warning caused by ourselves.
  if (preg_match('#Cannot modify header information - headers already sent by \\([^\\)]*[/\\\\]devel[/\\\\]#', $message)) {
    return;
  }
  if ($error_level & error_reporting()) {
    // Only write each distinct NOTICE message once, as repeats do not give any
    // further information and can choke the page output.
    if ($error_level == E_NOTICE) {
      static $written = [];
      if (!empty($written[$line][$filename][$message])) {
        return;
      }
      $written[$line][$filename][$message] = TRUE;
    }
    $types = drupal_error_levels();
    [$severity_msg, $severity_level] = $types[$error_level];
    $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    $caller = Error::getLastCaller($backtrace);
    $variables = [
      '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
      '@message' => $message,
      '%function' => $caller['function'],
      '%file' => $caller['file'],
      '%line' => $caller['line'],
    ];
    $msg = t('%type: @message in %function (line %line of %file).', $variables);
    // Show message if error_level is ERROR_REPORTING_DISPLAY_SOME or higher.
    // (This is Drupal's error_level, which is different from $error_level,
    // and we purposely ignore the difference between _SOME and _ALL,
    // see #970688!)
    if (Drupal::config('system.logging')->get('error_level') != 'hide') {
      $error_handlers = devel_get_handlers();
      if (!empty($error_handlers[DEVEL_ERROR_HANDLER_STANDARD])) {
        Drupal::messenger()->addMessage($msg, $severity_level <= RfcLogLevel::NOTICE ? MessengerInterface::TYPE_ERROR : MessengerInterface::TYPE_WARNING, TRUE);
      }
      if (!empty($error_handlers[DEVEL_ERROR_HANDLER_BACKTRACE_KINT])) {
        $input = ddebug_backtrace(return: TRUE, pop: 1);
        print Drupal::service('devel.dumper')->dumpOrExport(input: $input, name: $msg);
      }
      if (!empty($error_handlers[DEVEL_ERROR_HANDLER_BACKTRACE_DPM])) {
        $input = ddebug_backtrace(return: TRUE, pop: 1);
        Drupal::service('devel.dumper')->message(input: $input, name: $msg, type: MessengerInterface::TYPE_WARNING);
      }
    }
    Drupal::logger('php')->log($severity_level, $msg);
  }
}