2025-02-26 14:53:15 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2025 New Vector Ltd.
|
|
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
|
Please see LICENSE in the repository root for full details.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-02-27 09:26:38 +01:00
|
|
|
import { t } from "i18next";
|
|
|
|
|
|
2025-02-26 14:53:15 +01:00
|
|
|
export enum ErrorCode {
|
|
|
|
|
/**
|
|
|
|
|
* Configuration problem due to no MatrixRTC backend/SFU is exposed via .well-known and no fallback configured.
|
|
|
|
|
*/
|
2025-02-27 09:26:38 +01:00
|
|
|
MISSING_MATRIX_RTC_FOCUS = "MISSING_MATRIX_RTC_FOCUS",
|
2025-02-26 14:53:15 +01:00
|
|
|
CONNECTION_LOST_ERROR = "CONNECTION_LOST_ERROR",
|
2025-02-26 15:37:28 +01:00
|
|
|
// UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
2025-02-26 14:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-27 09:26:38 +01:00
|
|
|
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 ..
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-26 14:53:15 +01:00
|
|
|
/**
|
|
|
|
|
* Structure for errors that occur when using ElementCall.
|
|
|
|
|
*/
|
|
|
|
|
export class ElementCallError extends Error {
|
|
|
|
|
public code: ErrorCode;
|
2025-02-27 09:26:38 +01:00
|
|
|
public category: ErrorCategory;
|
|
|
|
|
public localisedMessage?: string;
|
2025-02-26 14:53:15 +01:00
|
|
|
|
2025-02-27 09:26:38 +01:00
|
|
|
public constructor(
|
|
|
|
|
name: string,
|
|
|
|
|
code: ErrorCode,
|
|
|
|
|
category: ErrorCategory,
|
|
|
|
|
localisedMessage?: string,
|
|
|
|
|
) {
|
|
|
|
|
super();
|
|
|
|
|
this.localisedMessage = localisedMessage;
|
|
|
|
|
this.category = category;
|
2025-02-26 14:53:15 +01:00
|
|
|
this.code = code;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-27 09:26:38 +01:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-26 14:53:15 +01:00
|
|
|
export class ConnectionLostError extends ElementCallError {
|
|
|
|
|
public constructor() {
|
2025-02-27 09:26:38 +01:00
|
|
|
super(
|
|
|
|
|
"Connection lost",
|
|
|
|
|
ErrorCode.CONNECTION_LOST_ERROR,
|
|
|
|
|
ErrorCategory.NETWORK_CONNECTIVITY,
|
|
|
|
|
);
|
2025-02-26 14:53:15 +01:00
|
|
|
}
|
|
|
|
|
}
|