P5.js-web-editor: Missing Console Errors - File Not Found

Created on 4 Nov 2017  路  12Comments  路  Source: processing/p5.js-web-editor

Starting over from #444, this github issue is to track error messages that show up in the native JS console, but not in the p5.js web editor console. To be clear, there are likely some error messages that should be hidden in the web editor console so this thread is also for discussion around these questions. This first issue contains a list of all the errors and subsequent comments will include specific code examples to trigger the missing error. Anyone should feel free to jump in and add to the comment thread and I'll keep the list below up to date!

  • [x] undefined values
  • [ ] file not found errors with loadJSON(), loadImage(), etc.
  • [x] incorrect renderer, i.e. only available with webgl, etc.

Tagging @almchung as this relates to the Friendly Error System.

help wanted high bug

Most helpful comment

i think it would make sense to beautify the error, rather than remove it. if a user switches their sketch to not use friendly errors (for example, they switch to using the minified p5.js), it would be cool if some error still appeared.

All 12 comments

Here's an example related to using an undefined string with text():

let txt;

function setup() { 
  createCanvas(400, 400);
  text(txt,100,100);
} 

JS console error: Cannot read property 'toString' of undefined

Another:

function setup() {
  let v;
  print(v);
}

Console should display: undefined

Here's an example related to "file not found":

let img;

function preload() {
  img = loadImage('missingfile.png');   
}

function setup() {}

JS console error: GET http://alpha.editor.p5js.org//missingfile.png 404 (Not Found)

Incorrect renderer:

function setup() { 
  createCanvas(400, 400);
} 

function draw() { 
  background(220);
  rotateZ(100);
}

Error should read: Uncaught not supported in p2d. Please use webgl mode

this has mostly been fixed, except for the file not found error. not sure why that's not getting to the console!

Is #868 a duplicate of this issue?

yep! they are the same issue.

@catarak I was looking through how errors are captured and thought this might help.

@shakeabi maybe! we're using the console-feed library, so i'm not sure if that error handler needs to be added in addition to console-feed.

Hey! I'm going to take a stab at the file not found issue. This is what I see happening in the editor:

Just want to clarify, would the fix be, instead of showing the Event object log, show the actual error message Failed to load resource: the server responded with a status of 404 ()?

After a bit of debugging and research, I have determined that the Failed to load resource: or GET http://localhost:8000//missingfile.png 404 (Not Found) error might not be interceptable as it is occurring at the network level.

One option, is to detect the failed to load image error provided by p5, and inject / emulate an error to match the network error. We might do that here

Thoughts?

Addition to @w3cj, currently we are using window.onerror to catch the error events. The 404 gets thrown from the image inside the iframe, then gets bubbled up to the window. In @w3cj's screenshot we also see the 404 message by the browsers network layer which, as far as i know is not interceptable and the other error with the Event object is the bubbled error event from the image. We could beautify this message or just remove it, because we already have the friendly error.

i think it would make sense to beautify the error, rather than remove it. if a user switches their sketch to not use friendly errors (for example, they switch to using the minified p5.js), it would be cool if some error still appeared.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hellonearthis picture hellonearthis  路  4Comments

zeyaoli picture zeyaoli  路  4Comments

byfelipesanchez picture byfelipesanchez  路  4Comments

aparrish picture aparrish  路  5Comments

aferriss picture aferriss  路  4Comments