From 3aefc6a4fad7ed7e901a87ad91658dff0bc5d4df Mon Sep 17 00:00:00 2001 From: Joel Purra Date: Thu, 12 May 2022 14:50:32 +0200 Subject: [PATCH] Fix UVC device not found detection/guessing --- src/camera-factory.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/camera-factory.ts b/src/camera-factory.ts index 16f2d88..25b88b1 100644 --- a/src/camera-factory.ts +++ b/src/camera-factory.ts @@ -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)}`;