Respect the result of any user-defined error handling #437
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current Situation
Currently the ErrorHandler will call any user-defined
set_error_handler
after Rollbar has processed all if its needs. However, if Rollbar decides to stop handling the error (if no logger is registered or the error is below the logger's base level) then the user's error handler is never called.Proposed Solution
The proposed solution will first call the user-defined
set_error_handler
. If the user's function returns a truthy value then Rollbar stops handling the error. A returned truthy value tells PHP to stop handling the error and is a way for user-defined error handlers to circumvent PHP's default methods.With this solution, any user-defined error handlers can suppress error messages and Rollbar won't pass them upstream.
Impetus
This PR comes from efforts to suppress a known warning triggered by WordPress in a PHP 7.2 environment. Our custom error handler to keep a harmless warning from flooding client sites is being ignored by Rollbar's error handler.