p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

Error when using loadJSON should catch error and not stop the process if there is an errorCallback

Open dievardump opened this issue 4 years ago • 1 comments
trafficstars

Most appropriate sub-area of p5.js?

  • [ ] Accessibility (Web Accessibility)
  • [ ] Build tools and processes
  • [ ] Color
  • [ ] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [ ] Events
  • [ ] Friendly error system
  • [ ] Image
  • [x] IO (Input/Output)
  • [ ] Localization
  • [ ] Math
  • [ ] Unit Testing
  • [ ] Typography
  • [ ] Utilities
  • [ ] WebGL
  • [ ] Other (specify if possible)

Details about the bug:

  • p5.js version: 1.3.1
  • Web browser and version: Firefox 88.0.1
  • Operating System: Linux
  • Steps to reproduce this:
let meta = { 
  // default value
  metadata: {}
};

function preload() {
  const uri = 'unknown.json';
  
  function onLoad(data) {
    meta.metadata = data;
  }
  
  function onError(error) {
    console.log(error);
  }
  
  loadJSON(uri, onLoad, onError);
}

function setup() {
  createcanvas(windowWidth, windowHeight);
  fill(255);
  rect(0, 0, 250, 250);
}

I am trying to fetch a file. This file can be present or not, therefore I have default data already set.

Since I provide an onError callback, It explicitly means that I wish to handle the error myself. I expect the error to be catched and passed to the onError callback, without stopping the current process.

However, here, the error is passed to onError but is not catched, so it propagates and stop everything from working.

dievardump avatar Jun 04 '21 01:06 dievardump

Possibly related to #5032

limzykenneth avatar Jun 06 '21 15:06 limzykenneth

same error in version 1.6.0

chepecarlos avatar Apr 07 '23 18:04 chepecarlos