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.
Goal
This PR adds a number of improvements to the error handler:
Because of these improvements we've also decided to always call the previous handlers, regardless of if
register
orregisterWithPrevious
is usedIt's still possible to prevent Bugsnag from calling the previous handlers like this:
Or the "chain" of error/exception handlers can be broken by creating handlers that do nothing:
Design
Some of the changes are a bit unintuitive, but the PHPT tests should show why they are necessary. The technique of re-throwing the exception inside the exception handler especially, but it's important to solve issues like #523 — this PR doesn't entirely fix that issue as we also need to re-raise exceptions when there is no previous handler, which will be done separately
Testing
Mostly tested through the PHPT tests and manually
The unit test has been re-written to use much less global mocking by setting/restoring error/exception handlers in the tests (one test still has a mocked global function). Unfortunately git tried too hard to diff the old & new file, so the diff is useless for reviewing☹️