Skip to content
Related Articles

Related Articles

p5.js disableFriendlyErrors Property
  • Last Updated : 22 Feb, 2021
GeeksforGeeks - Summer Carnival Banner

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

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :