Skip to content

Commit

Permalink
fix: console error object modified
Browse files Browse the repository at this point in the history
  • Loading branch information
hdz-666 committed Oct 29, 2024
1 parent 08ff473 commit f3ba7db
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/hms-video-store/src/error/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
13 changes: 13 additions & 0 deletions packages/hms-video-store/src/reactive-store/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/schema/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface HMSException {
isTerminal: boolean;
timestamp: Date;
nativeError?: Error;
deviceType?: string;
}

0 comments on commit f3ba7db

Please sign in to comment.