Skip to content

Web Editor can't capture and display errors for p5.js >= 1.0.0 #1546

@akshay-99

Description

@akshay-99

Nature of issue?

  • Found a bug

Details about the bug:

  • Web browser and version: Chrome 83.0.4103.116
  • Operating System: Ubuntu 18.04
  • Steps to reproduce this bug:

For sketches running on p5 versions 0.10.2 and older , the editor is able to capture an error, highlight the line and display the error in the editor console perfectly.
image
It cannot do the same for sketches running on newer versions of p5 ( >= 1.0.0 ) as seen here:
https://editor.p5js.org/akshay.padte/sketches/2yX5Q5CeV

This is likely because the initialization code for p5 was changed a bit in processing/p5.js#4233 ( just before 1.0.0 ) and it now runs inside a promise. Which also means that errors now happen inside a promise and would now be caught by unhandledrejection listener instead of onerror.

Also, since p5 0.6.0, several components of the FES report the line number of the error in the message. However since the editor concatenates the user-code into srcdoc, the line number reported by the FES is something like about:srcdoc:56:3
image

I was wondering if it's possible to fix this somehow. Maybe this belongs in an issue of its own.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueA beginner-friendly issue, great for first-time contributorsHelp WantedWould love additional input or contributions!Priority:HighShould be addressed soon but not critical

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions