Open In App

p5.js disableFriendlyErrors Property

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

The friendly error system (FES) is used to warn the user when the non-minified p5.js file (and not p5.min.js) is used. These friendly errors are not critical in nature, however having them in the console is disturbing. These can be turned off with the help of the disableFriendlyErrors property. This can also improve the performance of the sketch.

Note: Some friendly errors are important, like not inserting proper parameters in a function. These can cause problems in the program and disabling the errors makes it very hard to determine the actual cause. The default value of this property is false.

Syntax:

p5.disableFriendlyErrors = true;

Below example illustrates the disableFriendlyErrors property in p5.js:

Example 1:

Javascript




// This will disable friendly error messages
p5.disableFriendlyErrors = true;
  
// Notice that the spelling of preload is wrong
// This should throw a friendly error
// but it will not as they are disabled.
function preLoad() {
  console.log("hi");
}
  
function setup() {
  createCanvas(100, 100);
}
  
function draw() {
  background('green');
}


Output: No error message are shown in console

Example 2:

Javascript




// This will disable friendly error messages
p5.disableFriendlyErrors = true;
  
function setup() {
  createCanvas(100, 100);
}
  
function draw() {
  background('red');
  
  // This should throw a friendly error,
  // however it will not as they are disabled
  arc(1, 1, 10.5, 10);
}


Output: No error message are shown in console



Last Updated : 22 Feb, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads