Update FES check for internal errors to support ES6 classes #6244
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.
Resolves #6172
Changes
Previously, to tell if an error was internal, we'd see if the function name in the stack trace included
_main.default
, which used to be the case for allp5.prototype
functions. This seemed to no longer be the case for internal ES6 classes, so I've implemented a different method: throwing a test error, recording the filename, and then checking the real stack trace for frames originating in that same file.We also used to check all frames between the entrypoint (e.g. draw()) up to the source of the error looking for
_main.default
. I think this is because the error could have originated in a nonp5.prototype
function (like an anonymous function) that was called from ap5.prototype
function, and we want to catch that too. We don't need to loop using this new method, since both sorts of functions will originate from within the p5.js library file.We had an existing check for internal errors that used p5.Element. I've added a new test that does the same sort of thing but on p5.Framebuffer, which is an ES6 class.
PR Checklist
npm run lint
passes