Skip to content

Commit

Permalink
Merge pull request #6961 from mdb0/main
Browse files Browse the repository at this point in the history
add friendly error to createCapture()
  • Loading branch information
davepagurek authored Apr 22, 2024
2 parents bcb77cf + ef9af73 commit 1b140e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,14 @@ 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 1b140e3

Please sign in to comment.