Fix for #8398 - call failed-hook on compilation errors #8401
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.
See: #8398
fixes #8398
The problem: you currently can't use hooks to determine whether a compilation has failed. This makes it hard to wrap compilers with custom error handling. In master, the only time
hooks.failed
is called is when compilation fails during watch-mode. This PR calls the hook for normal compilations also.What kind of change does this PR introduce?
This PR ensures the failed-hooked is called whenever compilation fails.
The
finalCallback
(fromcompiler.run(finalCallback)
fame) is called as a bail-out whenever there's an error. So adding the call to the failed-hook here makes sense because it minimizes the code changes.Did you add tests for your changes?
Yes, added a test. To ensure this PR does the trick, either run the tests or the code below:
Does this PR introduce a breaking change?
As far as I can tell, it should not break anything. That is, unless folks have existing code for the failed-hook that they never expect to be called, which seems unlikely.
What needs to be documented once your changes are merged?
The docs actually already state the failed-hook is called on failure, so nothing should need to be updated. This PR just makes the behavior match the docs.