Update FES check for internal errors to support ES6 classes#6244
Merged
limzykenneth merged 1 commit intoprocessing:mainfrom Jun 29, 2023
Merged
Update FES check for internal errors to support ES6 classes#6244limzykenneth merged 1 commit intoprocessing:mainfrom
limzykenneth merged 1 commit intoprocessing:mainfrom
Conversation
Contributor
Author
|
Here's a web editor sketch with a build of this PR to test with live: https://editor.p5js.org/davepagurek/sketches/5r5496wuk |
Member
|
Looks good. Thanks! |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.prototypefunctions. 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.prototypefunction (like an anonymous function) that was called from ap5.prototypefunction, 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 lintpasses