ScriptLoader - fix error catching #7410
Merged
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.
Description
This PR aims to fix an issue with ScriptLoader not catching Throwables which aren't Exceptions (ie: StackOverflowError)
I noticed this while doing a test in Dev mode.
I made a booboo in SkBee here the toString of a condition was recursively calling itself.
Unfortunately the test just halted, it wouldn't fail, it wouldn't throw a StackOverflowError
Exhibit A:
Then I moved onto a script to test (not a Test test, just running a script).
I had a similar issue.
Exhibits B and C:
The parser just halted. No error, no stack overflow, nothing.
After a lengthy talk with Pickle, he came to the idea that it had to do with the CompletableFutures, as they weren't catching anything.
There are a bunch of Try/Catches in the ScriptLoader, but they catch Exceptions not Throwables.
StackOverflowError extends from Throwable, not exception.
By attaching an "Exceptionally" to the CF, we're able to catch all those pesky overflows (and other throwables)
Target Minecraft Versions: any
Requirements: none
Related Issues: none