Skip to content

Commit

Permalink
Update error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
DieterHolvoet committed Jun 20, 2021
1 parent dd9b692 commit 343f508
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.7.4] - 2021-03-14
## [1.7.5] - 2021-06-20
### Fixed
- Update error handler

## [1.7.4] - 2021-06-14
### Fixed
- Disable default exception, error & fatal error integrations to prevent duplicate events
- Allow events with empty or invalid IP addresses
Expand Down
27 changes: 17 additions & 10 deletions wmsentry.module
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,34 @@ function _wmsentry_error_handler_real($error_level, $message, $filename, $line,
_drupal_log_error([
'%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
// The standard PHP error handler considers that the error messages
// are HTML. We mimick this behavior here.
// are HTML. We mimic this behavior here.
'@message' => Markup::create(Xss::filterAdmin($message)),
'%function' => $caller['function'],
'%file' => $caller['file'],
'%line' => $caller['line'],
'severity_level' => $severity_level,
'backtrace' => $backtrace,
'@backtrace_string' => (new \Exception())->getTraceAsString(),
'exception' => NULL,
], $recoverable || $to_string);
}
// If the site is a test site then fail for user deprecations so they can be
// caught by the deprecation error handler.
elseif (DRUPAL_TEST_IN_CHILD_SITE && $error_level === E_USER_DEPRECATED) {
$backtrace = debug_backtrace();
$caller = Error::getLastCaller($backtrace);
_drupal_error_header(
Markup::create(Xss::filterAdmin($message)),
'User deprecated function',
$caller['function'],
$caller['file'],
$caller['line']
);
static $seen = [];
if (array_search($message, $seen, TRUE) === FALSE) {
// Only report each deprecation once. Too many headers can break some
// Chrome and web driver testing.
$seen[] = $message;
$backtrace = debug_backtrace();
$caller = Error::getLastCaller($backtrace);
_drupal_error_header(
Markup::create(Xss::filterAdmin($message)),
'User deprecated function',
$caller['function'],
$caller['file'],
$caller['line']
);
}
}
}

0 comments on commit 343f508

Please sign in to comment.