Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FES check for internal errors to support ES6 classes #6244

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

davepagurek
Copy link
Contributor

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 all p5.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 non p5.prototype function (like an anonymous function) that was called from a p5.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
  • [Inline documentation] is included / updated
  • [Unit tests] are included / updated

@davepagurek
Copy link
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

@limzykenneth limzykenneth merged commit 2a1bb03 into processing:main Jun 29, 2023
5 checks passed
@limzykenneth
Copy link
Member

Looks good. Thanks!

@davepagurek davepagurek mentioned this pull request Jun 29, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check for whether an error is internal needs updating for ES6 classes
2 participants