0

So I've got a web app that uses the webcam to take photos. It's used by our staff who are not very technical. A frequent issue that occurs is they will accidentally open two windows with the app. I made the page display the console in the webpage, but with all the other information that is displayed in the console, they often won't notice the error, and also the error isn't clear what it means. The error is:

NotReadableError: Could not start video source

Is there a way to watch for this error, and display an HTML element (I'm thinking a hovering red bar over the video area) that explains that the camera is being used by another window/browser/tab.

any information would be a huge help.

Sam
  • 65
  • 8
  • `try { logic } catch (e) { do whatever with e.message }` – Ravenous Apr 24 '20 at 23:00
  • @Ravenous Is there a way to specify the message that triggers the catch? I don't want it to fire off on every single message as I have quite a few console calls for debugging (stuff like the camera resolution the browser detects, the size of the photo that is created, if the photo had to be compressed at a lower quality to reach it's size target, etc) If you know a resource where I could learn more about browser errors that might point me in the right direction, that would be huge, because I just don't know where to start with this. – Sam Apr 24 '20 at 23:13
  • You need to wrap your "start camera logic" in try catch, not everything, and that catches only errors, not `console.log/warn/error`, strictly thrown exceptions via 'throw`. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch – Ravenous Apr 24 '20 at 23:19
  • also https://stackoverflow.com/questions/1433558/handling-specific-errors-in-javascript-think-exceptions – Ravenous Apr 24 '20 at 23:22

0 Answers0