Web Editor can't capture and display errors for p5.js >= 1.0.0 #1546
Labels
Good First Issue
A beginner-friendly issue, great for first-time contributors
Help Wanted
Would love additional input or contributions!
Priority:High
Should be addressed soon but not critical
Nature of issue?
Details about the 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.

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 ofonerror
.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 likeabout:srcdoc:56:3
I was wondering if it's possible to fix this somehow. Maybe this belongs in an issue of its own.
The text was updated successfully, but these errors were encountered: