Skip to content

Commit d9ab333

Browse files
authored
Merge pull request #8622 from MASTERsj01/fix/console-log-to-fes-dev2
fix: replace raw console.log calls with p5._friendlyError across multiple modules (addresses #8621)
2 parents 666c425 + a9c925d commit d9ab333

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

src/data/local_storage.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,20 @@ function storage(p5, fn){
114114
*/
115115
fn.storeItem = function(key, value) {
116116
if (typeof key !== 'string') {
117-
console.log(
118-
`The argument that you passed to storeItem() - ${key} is not a string.`
117+
p5._friendlyError(
118+
`The argument that you passed to storeItem() - ${key} is not a string.`,
119+
'storeItem'
119120
);
120121
}
121122
if (key.endsWith('p5TypeID')) {
122-
console.log(
123-
`The argument that you passed to storeItem() - ${key} must not end with 'p5TypeID'.`
123+
p5._friendlyError(
124+
`The argument that you passed to storeItem() - ${key} must not end with 'p5TypeID'.`,
125+
'storeItem'
124126
);
125127
}
126128

127129
if (typeof value === 'undefined') {
128-
console.log('You cannot store undefined variables using storeItem().');
130+
p5._friendlyError('You cannot store undefined variables using storeItem().', 'storeItem');
129131
}
130132
let type = typeof value;
131133
switch (type) {
@@ -263,8 +265,9 @@ function storage(p5, fn){
263265
let value = localStorage.getItem(key);
264266
const type = localStorage.getItem(`${key}p5TypeID`);
265267
if (typeof type === 'undefined') {
266-
console.log(
267-
`Unable to determine type of item stored under ${key}in local storage. Did you save the item with something other than setItem()?`
268+
p5._friendlyError(
269+
`Unable to determine type of item stored under ${key}in local storage. Did you save the item with something other than setItem()?`,
270+
'getItem'
268271
);
269272
} else if (value !== null) {
270273
switch (type) {
@@ -418,8 +421,9 @@ function storage(p5, fn){
418421
*/
419422
fn.removeItem = function(key) {
420423
if (typeof key !== 'string') {
421-
console.log(
422-
`The argument that you passed to removeItem() - ${key} is not a string.`
424+
p5._friendlyError(
425+
`The argument that you passed to removeItem() - ${key} is not a string.`,
426+
'removeItem'
423427
);
424428
}
425429
localStorage.removeItem(key);

src/dom/dom.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,8 +1832,9 @@ function dom(p5, fn){
18321832

18331833
// If File API's are not supported, throw Error
18341834
if (!(window.File && window.FileReader && window.FileList && window.Blob)) {
1835-
console.log(
1836-
'The File APIs are not fully supported in this browser. Cannot create element.'
1835+
p5._friendlyError(
1836+
'The File APIs are not fully supported in this browser. Cannot create element.',
1837+
'createFileInput'
18371838
);
18381839
return;
18391840
}

src/dom/p5.MediaElement.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,6 @@ class MediaElement extends Element {
11701170
removeCue(id) {
11711171
for (let i = 0; i < this._cues.length; i++) {
11721172
if (this._cues[i].id === id) {
1173-
console.log(id);
11741173
this._cues.splice(i, 1);
11751174
}
11761175
}

src/events/pointer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ function pointer(p5, fn, lifecycles){
18611861
canvas.requestPointerLock =
18621862
canvas.requestPointerLock || canvas.mozRequestPointerLock;
18631863
if (!canvas.requestPointerLock) {
1864-
console.log('requestPointerLock is not implemented in this browser');
1864+
p5._friendlyError('requestPointerLock is not implemented in this browser', 'requestPointerLock');
18651865
return false;
18661866
}
18671867
canvas.requestPointerLock();

src/image/p5.Image.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,8 +1605,9 @@ class Image {
16051605
props.displayIndex = index;
16061606
this.drawingContext.putImageData(props.frames[index].image, 0, 0);
16071607
} else {
1608-
console.log(
1609-
'Cannot set GIF to a frame number that is higher than total number of frames or below zero.'
1608+
p5._friendlyError(
1609+
'Cannot set GIF to a frame number that is higher than total number of frames or below zero.',
1610+
'setFrame'
16101611
);
16111612
}
16121613
}

0 commit comments

Comments
 (0)