From d5a3087ce6f80e604034522bbbdd6424f4607226 Mon Sep 17 00:00:00 2001 From: mdb0 <96520668+mdb0@users.noreply.github.com> Date: Fri, 12 Apr 2024 01:50:14 +0200 Subject: [PATCH 1/2] add friendly error to createCapture() --- src/dom/dom.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 7fb5bf4b45..e6cf70394c 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -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; From ef9af73f463b0d6ab7f5325242526e07d6203c41 Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Mon, 22 Apr 2024 12:55:01 -0400 Subject: [PATCH 2/2] Remove trailing spaces causing tests to fail --- src/dom/dom.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index e6cf70394c..9829776e81 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -2439,7 +2439,6 @@ p5.prototype.createCapture = function(...args) { domElement.src = stream; } }).catch(e => { - if (e.name === 'NotFoundError') p5._friendlyError('No webcam found on this device', 'createCapture'); if (e.name === 'NotAllowedError')