Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced all console.error with p5._friendlyError #6674

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ module.exports = (data, options) => {
ci => !ci.itemtype && (ci.params || ci.return) && ci.access !== 'private'
)
.forEach(ci => {
console.error(ci.file + ':' + ci.line + ': unnamed public member');
p5._friendlyError(ci.file + ':' + ci.line + ': unnamed public member');
});

Object.keys(data.classes)
Expand Down
2 changes: 1 addition & 1 deletion docs/yuidoc-p5-theme/assets/js/vendor/ace-nc/ace.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions lib/addons/p5.sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ function () {
err.msg = msg;
errorCallback(err);
} else {
console.error(msg + '\n The error stack trace includes: \n' + err.stack);
p5._friendlyError(msg + '\n The error stack trace includes: \n' + err.stack);
}
});
}
Expand All @@ -1600,7 +1600,7 @@ function () {
err.message = msg;
errorCallback(err);
} else {
console.error(msg + '\n The error stack trace includes: \n' + err.stack);
p5._friendlyError(msg + '\n The error stack trace includes: \n' + err.stack);
}
}
};
Expand All @@ -1614,7 +1614,7 @@ function () {
err.message = msg;
errorCallback(err);
} else {
console.error(msg + '\n The error stack trace includes: \n' + err.stack);
p5._friendlyError(msg + '\n The error stack trace includes: \n' + err.stack);
}
};

Expand Down Expand Up @@ -6165,7 +6165,7 @@ function () {
self.amplitude.setInput(self.output);
if (successCallback) successCallback();
})["catch"](function (err) {
if (errorCallback) errorCallback(err);else console.error(err);
if (errorCallback) errorCallback(err);else p5._friendlyError(err);
});
}
/**
Expand Down Expand Up @@ -6332,7 +6332,7 @@ function () {
if (onError) {
onError(error);
} else {
console.error('This browser does not support MediaStreamTrack.getSources()');
p5._friendlyError('This browser does not support MediaStreamTrack.getSources()');
}
});
});
Expand Down Expand Up @@ -7281,7 +7281,7 @@ function (_Effect) {
this.bands[i / 2].gain(arguments[i + 1]);
}
} else {
console.error('Argument mismatch. .set() should be called with ' + this.bands.length * 2 + ' arguments. (one frequency and gain value pair for each band of the eq)');
p5._friendlyError('Argument mismatch. .set() should be called with ' + this.bands.length * 2 + ' arguments. (one frequency and gain value pair for each band of the eq)');
}
}
/**
Expand Down Expand Up @@ -8702,7 +8702,7 @@ function (_Reverb) {
err.msg = msg;
errorCallback(err);
} else {
console.error(msg + '\n The error stack trace includes: \n' + err.stack);
p5._friendlyError(msg + '\n The error stack trace includes: \n' + err.stack);
}
});
}
Expand All @@ -8714,7 +8714,7 @@ function (_Reverb) {
err.message = msg;
errorCallback(err);
} else {
console.error(msg + '\n The error stack trace includes: \n' + err.stack);
p5._friendlyError(msg + '\n The error stack trace includes: \n' + err.stack);
}
}
};
Expand All @@ -8728,7 +8728,7 @@ function (_Reverb) {
err.message = msg;
errorCallback(err);
} else {
console.error(msg + '\n The error stack trace includes: \n' + err.stack);
p5._friendlyError(msg + '\n The error stack trace includes: \n' + err.stack);
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3799,11 +3799,11 @@ class MediaElement extends p5.Element {
if (typeof IS_MINIFIED === 'undefined') {
p5._friendlyAutoplayError(this.src);
} else {
console.error(e);
p5._friendlyError(e);
}
} else {
// any other kind of error
console.error('Media play method encountered an unexpected error', e);
p5._friendlyError('Media play method encountered an unexpected error', e);
}
});
}
Expand Down Expand Up @@ -4043,7 +4043,7 @@ class MediaElement extends p5.Element {
if (typeof IS_MINIFIED === 'undefined') {
p5._friendlyAutoplayError(this.src);
} else {
console.error(e);
p5._friendlyError(e);
}
}, 500);
this.elt.addEventListener('play', () => clearTimeout(timeout), {
Expand Down
10 changes: 5 additions & 5 deletions src/image/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import '../core/friendly_errors/fes_core';
* }
*
* function failure(event) {
* console.error('Oops!', event);
* p5._friendlyError('Oops!', event);
* }
* </code>
* </div>
Expand Down Expand Up @@ -129,7 +129,7 @@ p5.prototype.loadImage = function(path, successCallback, failureCallback) {
failureCallback(e);
self._decrementPreload();
} else {
console.error(e);
p5._friendlyError(e);
}
}
);
Expand All @@ -156,7 +156,7 @@ p5.prototype.loadImage = function(path, successCallback, failureCallback) {
failureCallback(e);
self._decrementPreload();
} else {
console.error(e);
p5._friendlyError(e);
}
};

Expand All @@ -179,7 +179,7 @@ p5.prototype.loadImage = function(path, successCallback, failureCallback) {
failureCallback(e);
self._decrementPreload();
} else {
console.error(e);
p5._friendlyError(e);
}
});
return pImg;
Expand Down Expand Up @@ -604,7 +604,7 @@ function _createGif(
if (typeof failureCallback === 'function') {
failureCallback(e);
} else {
console.error(e);
p5._friendlyError(e);
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/io/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ p5.prototype.loadTable = function(path) {
if (errorCallback) {
errorCallback(err);
} else {
console.error(err);
p5._friendlyError(err);
}
}
);
Expand Down Expand Up @@ -1125,7 +1125,7 @@ p5.prototype.httpDo = function(...args) {
}
});
promise.then(callback || (() => {}));
promise.catch(errorCallback || console.error);
promise.catch(errorCallback || p5._friendlyError);
return promise;
};

Expand Down
4 changes: 2 additions & 2 deletions src/typography/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ import '../core/friendly_errors/fes_core';
* }
*
* function failure(event) {
* console.error('Oops!', event);
* p5._friendlyError('Oops!', event);
* }
* </code>
* </div>
Expand Down Expand Up @@ -137,7 +137,7 @@ p5.prototype.loadFont = function(path, onSuccess, onError) {
if (typeof onError !== 'undefined') {
return onError(err);
}
console.error(err, path);
p5._friendlyError(err, path);
return;
}

Expand Down
26 changes: 13 additions & 13 deletions src/webgl/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ function parseASCIISTL(model, lines) {
case '': // First run
if (parts[0] !== 'solid') {
// Invalid state
console.error(line);
console.error(`Invalid state "${parts[0]}", should be "solid"`);
p5._friendlyError(line);
p5._friendlyError(`Invalid state "${parts[0]}", should be "solid"`);
return;
} else {
state = 'solid';
Expand All @@ -489,8 +489,8 @@ function parseASCIISTL(model, lines) {
case 'solid': // First face
if (parts[0] !== 'facet' || parts[1] !== 'normal') {
// Invalid state
console.error(line);
console.error(
p5._friendlyError(line);
p5._friendlyError(
`Invalid state "${parts[0]}", should be "facet normal"`
);
return;
Expand All @@ -509,8 +509,8 @@ function parseASCIISTL(model, lines) {
case 'facet normal': // After normal is defined
if (parts[0] !== 'outer' || parts[1] !== 'loop') {
// Invalid State
console.error(line);
console.error(`Invalid state "${parts[0]}", should be "outer loop"`);
p5._friendlyError(line);
p5._friendlyError(`Invalid state "${parts[0]}", should be "outer loop"`);
return;
} else {
// Next should be vertices
Expand All @@ -536,8 +536,8 @@ function parseASCIISTL(model, lines) {
state = 'endloop';
} else {
// Invalid State
console.error(line);
console.error(
p5._friendlyError(line);
p5._friendlyError(
`Invalid state "${parts[0]}", should be "vertex" or "endloop"`
);
return;
Expand All @@ -547,8 +547,8 @@ function parseASCIISTL(model, lines) {
case 'endloop':
if (parts[0] !== 'endfacet') {
// End of face
console.error(line);
console.error(`Invalid state "${parts[0]}", should be "endfacet"`);
p5._friendlyError(line);
p5._friendlyError(`Invalid state "${parts[0]}", should be "endfacet"`);
return;
} else {
state = 'endfacet';
Expand All @@ -569,8 +569,8 @@ function parseASCIISTL(model, lines) {
state = 'facet normal';
} else {
// Invalid State
console.error(line);
console.error(
p5._friendlyError(line);
p5._friendlyError(
`Invalid state "${
parts[0]
}", should be "endsolid" or "facet normal"`
Expand All @@ -580,7 +580,7 @@ function parseASCIISTL(model, lines) {
break;

default:
console.error(`Invalid state "${state}"`);
p5._friendlyError(`Invalid state "${state}"`);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/webgl/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ p5.prototype.loadShader = function (
) {
p5._validateParameters('loadShader', arguments);
if (!errorCallback) {
errorCallback = console.error;
errorCallback = p5._friendlyError;
}

const loadedShader = new p5.Shader();
Expand Down Expand Up @@ -1295,7 +1295,7 @@ p5.RendererGL.prototype._applyBlendMode = function () {
}
break;
default:
console.error(
p5._friendlyError(
'Oops! Somehow RendererGL set curBlendMode to an unsupported mode.'
);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/webgl/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import './p5.RendererGL.Retained';
// @TODO:
p5.RendererGL.prototype._applyTextProperties = function() {
//@TODO finish implementation
//console.error('text commands not yet implemented in webgl');
//p5._friendlyError('text commands not yet implemented in webgl');
};

p5.RendererGL.prototype.textWidth = function(s) {
Expand Down
2 changes: 1 addition & 1 deletion tasks/test/mocha-chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async function saveCoverage(cov) {
await mkdir('./.nyc_output/', { recursive: true });
await writeFile('./.nyc_output/out.json', JSON.stringify(cov));
} catch (e) {
console.error(e);
p5._friendlyError(e);
}
}
}