Skip to content

Commit

Permalink
add friendly error to createCapture()
Browse files Browse the repository at this point in the history
  • Loading branch information
mdb0 authored Apr 11, 2024
1 parent cf94f56 commit d5a3087
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,15 @@ p5.prototype.createCapture = function(...args) {
catch(err) {
domElement.src = stream;
}
}, console.error);
}).catch(e => {

if (e.name === 'NotFoundError')
p5._friendlyError('No webcam found on this device', 'createCapture');
if (e.name === 'NotAllowedError')
p5._friendlyError('Access to the camera was denied', 'createCapture');

console.error(e);
});

const videoEl = addElement(domElement, this, true);
videoEl.loadedmetadata = false;
Expand Down

0 comments on commit d5a3087

Please sign in to comment.