refactor: Centralize group call errors in custom GroupCallErrorBoundary
This commit is contained in:
@@ -13,6 +13,9 @@ export enum ErrorCode {
|
||||
*/
|
||||
MISSING_MATRIX_RTC_FOCUS = "MISSING_MATRIX_RTC_FOCUS",
|
||||
CONNECTION_LOST_ERROR = "CONNECTION_LOST_ERROR",
|
||||
/** LiveKit indicates that the server has hit its track limits */
|
||||
INSUFFICIENT_CAPACITY_ERROR = "INSUFFICIENT_CAPACITY_ERROR",
|
||||
E2EE_NOT_SUPPORTED = "E2EE_NOT_SUPPORTED",
|
||||
UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
||||
}
|
||||
|
||||
@@ -20,6 +23,7 @@ export enum ErrorCategory {
|
||||
/** Calling is not supported, server misconfigured (JWT service missing, no MSC support ...)*/
|
||||
CONFIGURATION_ISSUE = "CONFIGURATION_ISSUE",
|
||||
NETWORK_CONNECTIVITY = "NETWORK_CONNECTIVITY",
|
||||
CLIENT_CONFIGURATION = "CLIENT_CONFIGURATION",
|
||||
UNKNOWN = "UNKNOWN",
|
||||
// SYSTEM_FAILURE / FEDERATION_FAILURE ..
|
||||
}
|
||||
@@ -31,14 +35,17 @@ export class ElementCallError extends Error {
|
||||
public code: ErrorCode;
|
||||
public category: ErrorCategory;
|
||||
public localisedMessage?: string;
|
||||
public localisedTitle: string;
|
||||
|
||||
public constructor(
|
||||
name: string,
|
||||
protected constructor(
|
||||
localisedTitle: string,
|
||||
code: ErrorCode,
|
||||
category: ErrorCategory,
|
||||
localisedMessage?: string,
|
||||
localisedMessage: string,
|
||||
cause?: Error,
|
||||
) {
|
||||
super(name);
|
||||
super(localisedTitle, { cause });
|
||||
this.localisedTitle = localisedTitle;
|
||||
this.localisedMessage = localisedMessage;
|
||||
this.category = category;
|
||||
this.code = code;
|
||||
@@ -50,7 +57,7 @@ export class MatrixRTCFocusMissingError extends ElementCallError {
|
||||
|
||||
public constructor(domain: string) {
|
||||
super(
|
||||
"MatrixRTCFocusMissingError",
|
||||
t("error.call_is_not_supported"),
|
||||
ErrorCode.MISSING_MATRIX_RTC_FOCUS,
|
||||
ErrorCategory.CONFIGURATION_ISSUE,
|
||||
t("error.matrix_rtc_focus_missing", {
|
||||
@@ -66,9 +73,45 @@ export class MatrixRTCFocusMissingError extends ElementCallError {
|
||||
export class ConnectionLostError extends ElementCallError {
|
||||
public constructor() {
|
||||
super(
|
||||
"Connection lost",
|
||||
t("error.connection_lost"),
|
||||
ErrorCode.CONNECTION_LOST_ERROR,
|
||||
ErrorCategory.NETWORK_CONNECTIVITY,
|
||||
t("error.connection_lost_description"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class E2EENotSupportedError extends ElementCallError {
|
||||
public constructor() {
|
||||
super(
|
||||
t("error.e2ee_unsupported"),
|
||||
ErrorCode.E2EE_NOT_SUPPORTED,
|
||||
ErrorCategory.CLIENT_CONFIGURATION,
|
||||
t("error.e2ee_unsupported_description"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class UnknownCallError extends ElementCallError {
|
||||
public constructor(error: Error) {
|
||||
super(
|
||||
t("error.generic"),
|
||||
ErrorCode.UNKNOWN_ERROR,
|
||||
ErrorCategory.UNKNOWN,
|
||||
error.message,
|
||||
// Properly set it as a cause for a better reporting on sentry
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class InsufficientCapacityError extends ElementCallError {
|
||||
public constructor() {
|
||||
super(
|
||||
t("error.insufficient_capacity"),
|
||||
ErrorCode.INSUFFICIENT_CAPACITY_ERROR,
|
||||
ErrorCategory.UNKNOWN,
|
||||
t("error.insufficient_capacity_description"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user