From f3ba7db28e1a5f7243711e2eecd38645cc4c7099 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:50:59 +0530 Subject: [PATCH] fix: console error object modified --- packages/hms-video-store/src/error/utils.ts | 13 +++++++++---- .../hms-video-store/src/reactive-store/adapter.ts | 13 +++++++++++++ packages/hms-video-store/src/schema/error.ts | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/hms-video-store/src/error/utils.ts b/packages/hms-video-store/src/error/utils.ts index 16b31937a6..370f1202fd 100644 --- a/packages/hms-video-store/src/error/utils.ts +++ b/packages/hms-video-store/src/error/utils.ts @@ -13,13 +13,18 @@ export enum HMSGetMediaActions { function getDefaultError(error: string, deviceInfo: string) { const message = error.toLowerCase(); + let exception = ErrorFactory.TracksErrors.GenericTrack(HMSAction.TRACK, error); + if (message.includes('device not found')) { - return ErrorFactory.TracksErrors.DeviceNotAvailable(HMSAction.TRACK, deviceInfo, error); + exception = ErrorFactory.TracksErrors.DeviceNotAvailable(HMSAction.TRACK, deviceInfo, error); } else if (message.includes('permission denied')) { - return ErrorFactory.TracksErrors.CantAccessCaptureDevice(HMSAction.TRACK, deviceInfo, error); - } else { - return ErrorFactory.TracksErrors.GenericTrack(HMSAction.TRACK, error); + exception = ErrorFactory.TracksErrors.CantAccessCaptureDevice(HMSAction.TRACK, deviceInfo, error); + } + if (deviceInfo) { + exception.addDeviceType(deviceInfo); } + + return exception; } /** diff --git a/packages/hms-video-store/src/reactive-store/adapter.ts b/packages/hms-video-store/src/reactive-store/adapter.ts index c765a4c8b3..8f2fa0ed0b 100644 --- a/packages/hms-video-store/src/reactive-store/adapter.ts +++ b/packages/hms-video-store/src/reactive-store/adapter.ts @@ -204,6 +204,19 @@ export class SDKToHMS { } static convertException(sdkException: sdkTypes.HMSException): HMSException { + if (sdkException.deviceType) { + return { + code: sdkException.code, + action: sdkException.action, + name: sdkException.name, + message: sdkException.message, + description: sdkException.description, + isTerminal: sdkException.isTerminal, + nativeError: sdkException.nativeError, + deviceType: sdkException.deviceType, + timestamp: new Date(), + }; + } return { code: sdkException.code, action: sdkException.action, diff --git a/packages/hms-video-store/src/schema/error.ts b/packages/hms-video-store/src/schema/error.ts index 7a19a4a7a0..285565d740 100644 --- a/packages/hms-video-store/src/schema/error.ts +++ b/packages/hms-video-store/src/schema/error.ts @@ -10,4 +10,5 @@ export interface HMSException { isTerminal: boolean; timestamp: Date; nativeError?: Error; + deviceType?: string; }