Skip to content

Commit

Permalink
fix: add new changes for metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
hdz-666 committed Oct 30, 2024
1 parent 7f1e659 commit 75d9fa4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/hms-video-store/src/error/HMSException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider
public message: string,
public description: string,
public isTerminal: boolean = false,
public deviceType: string = '',
public metadata: Record<string, any> = {},
) {
super(message);

Expand All @@ -30,7 +30,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider
error_description: this.description,
action: this.action,
is_terminal: this.isTerminal,
device_type: this.deviceType,
metadata: this.metadata,
};
}

Expand All @@ -39,8 +39,8 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider
}

//add method to set HMSGetMediaActions as deviceType
addDeviceType(deviceType: string) {
this.deviceType = deviceType;
addMetadata(metadata: Record<string, any>) {
this.metadata = metadata;
}

toString() {
Expand All @@ -52,7 +52,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider
description: ${this.description};
isTerminal: ${this.isTerminal};
nativeError: ${this.nativeError?.message};
deviceType: ${this.deviceType};
metadata: ${this.metadata};
}`;
}
}
3 changes: 2 additions & 1 deletion packages/hms-video-store/src/error/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function convertMediaErrorToHMSException(err: Error, deviceInfo = ''): HMSExcept
export function BuildGetMediaError(err: Error, deviceInfo: string): HMSException {
const exception = convertMediaErrorToHMSException(err, deviceInfo);
exception.addNativeError(err);
exception.addDeviceType(deviceInfo);
const device = { deviceType: deviceInfo };
exception.addMetadata(device);
return exception;
}
4 changes: 2 additions & 2 deletions packages/hms-video-store/src/reactive-store/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ export class SDKToHMS {
nativeError: sdkException.nativeError,
timestamp: new Date(),
} as HMSException;
if (sdkException.deviceType) {
exp.deviceType = sdkException.deviceType;
if (sdkException.metadata) {
exp.metadata = sdkException.metadata;
}
return exp;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hms-video-store/src/schema/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export interface HMSException {
isTerminal: boolean;
timestamp: Date;
nativeError?: Error;
deviceType?: string;
metadata?: Record<string, any>;
}

0 comments on commit 75d9fa4

Please sign in to comment.