Skip to content

Commit

Permalink
Fix UVC device not found detection/guessing
Browse files Browse the repository at this point in the history
  • Loading branch information
joelpurra committed May 12, 2022
1 parent 999c7d5 commit 3aefc6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/camera-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ export default class CameraFactory {
const guessThatUvcDeviceWasNotFound = typeof error.name === "string"
&& error.name === "TypeError"
&& typeof error.message === "string"
&& error.message === "Cannot read property 'interfaces' of undefined";
&& (
// NOTE: message formatting differs across versions; could use a regular expression instead.
error.message === "Cannot read property 'interfaces' of undefined"
|| error.message === "Cannot read properties of undefined (reading 'interfaces')"
);

errorMessage = guessThatUvcDeviceWasNotFound ? `Could not find UVC device. Is a compatible camera connected? ${JSON.stringify(getFunctionArguments)}` : `Could create uvc-control object: ${JSON.stringify(constructorOptions)}`;

Expand Down

0 comments on commit 3aefc6a

Please sign in to comment.