mirror of
https://github.com/vector-im/element-call.git
synced 2026-02-08 04:19:11 +00:00
review: Improve error structure + better RTCFocus error message
This commit is contained in:
@@ -5,29 +5,68 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { t } from "i18next";
|
||||
|
||||
export enum ErrorCode {
|
||||
/**
|
||||
* Configuration problem due to no MatrixRTC backend/SFU is exposed via .well-known and no fallback configured.
|
||||
*/
|
||||
MISSING_LIVE_KIT_SERVICE_URL = "MISSING_LIVE_KIT_SERVICE_URL",
|
||||
MISSING_MATRIX_RTC_FOCUS = "MISSING_MATRIX_RTC_FOCUS",
|
||||
CONNECTION_LOST_ERROR = "CONNECTION_LOST_ERROR",
|
||||
// UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
||||
}
|
||||
|
||||
export enum ErrorCategory {
|
||||
/** Calling is not supported, server miss-configured (JWT service missing, no MSC support ...)*/
|
||||
CONFIGURATION_ISSUE = "CONFIGURATION_ISSUE",
|
||||
NETWORK_CONNECTIVITY = "NETWORK_CONNECTIVITY",
|
||||
// SYSTEM_FAILURE / FEDERATION_FAILURE ..
|
||||
}
|
||||
|
||||
/**
|
||||
* Structure for errors that occur when using ElementCall.
|
||||
*/
|
||||
export class ElementCallError extends Error {
|
||||
public code: ErrorCode;
|
||||
public category: ErrorCategory;
|
||||
public localisedMessage?: string;
|
||||
|
||||
public constructor(message: string, code: ErrorCode) {
|
||||
super(message);
|
||||
public constructor(
|
||||
name: string,
|
||||
code: ErrorCode,
|
||||
category: ErrorCategory,
|
||||
localisedMessage?: string,
|
||||
) {
|
||||
super();
|
||||
this.localisedMessage = localisedMessage;
|
||||
this.category = category;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
export class MatrixRTCFocusMissingError extends ElementCallError {
|
||||
public domain: string;
|
||||
|
||||
public constructor(domain: string) {
|
||||
super(
|
||||
"MatrixRTCFocusMissingError",
|
||||
ErrorCode.MISSING_MATRIX_RTC_FOCUS,
|
||||
ErrorCategory.CONFIGURATION_ISSUE,
|
||||
t("error.matrix_rtc_focus_missing", {
|
||||
brand: domain,
|
||||
errorCode: ErrorCode.MISSING_MATRIX_RTC_FOCUS,
|
||||
}),
|
||||
);
|
||||
this.domain = domain;
|
||||
}
|
||||
}
|
||||
|
||||
export class ConnectionLostError extends ElementCallError {
|
||||
public constructor() {
|
||||
super("Connection lost", ErrorCode.CONNECTION_LOST_ERROR);
|
||||
super(
|
||||
"Connection lost",
|
||||
ErrorCode.CONNECTION_LOST_ERROR,
|
||||
ErrorCategory.NETWORK_CONNECTIVITY,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user