p5.js disableFriendlyErrors Property
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
p5.disableFriendlyErrors = true ;
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
p5.disableFriendlyErrors = true ;
function setup() {
createCanvas(100, 100);
}
function draw() {
background( 'red' );
arc(1, 1, 10.5, 10);
}
|
Output: No error message are shown in console
Last Updated :
22 Feb, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...