diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index 71c1cc48..be1ed14c 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -44,7 +44,7 @@ import { CallEndedView } from "./CallEndedView"; import { PosthogAnalytics } from "../analytics/PosthogAnalytics"; import { useProfile } from "../profile/useProfile"; import { findDeviceByName } from "../utils/media"; -import { ActiveCall, ConnectionLostError } from "./InCallView"; +import { ActiveCall } from "./InCallView"; import { MUTE_PARTICIPANT_COUNT, type MuteStates } from "./MuteStates"; import { useMediaDevices } from "../livekit/MediaDevicesContext"; import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships"; @@ -61,6 +61,7 @@ import { callEventAudioSounds } from "./CallEventAudioRenderer"; import { useLatest } from "../useLatest"; import { usePageTitle } from "../usePageTitle"; import { ErrorView } from "../ErrorView"; +import { ConnectionLostError, ElementCallError } from "../utils/ec-errors.ts"; declare global { interface Window { diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index c0ee0711..bd6098ff 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -97,13 +97,12 @@ import { useSetting, } from "../settings/settings"; import { ReactionsReader } from "../reactions/ReactionsReader"; +import { ConnectionLostError } from "../utils/ec-errors.ts"; const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); const maxTapDurationMs = 400; -export class ConnectionLostError extends Error {} - export interface ActiveCallProps extends Omit { e2eeSystem: EncryptionSystem; diff --git a/src/utils/ec-errors.ts b/src/utils/ec-errors.ts new file mode 100644 index 00000000..6e3018b7 --- /dev/null +++ b/src/utils/ec-errors.ts @@ -0,0 +1,33 @@ +/* +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. +*/ + +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", + CONNECTION_LOST_ERROR = "CONNECTION_LOST_ERROR", + UNKNOWN_ERROR = "UNKNOWN_ERROR", +} + +/** + * Structure for errors that occur when using ElementCall. + */ +export class ElementCallError extends Error { + public code: ErrorCode; + + public constructor(message: string, code: ErrorCode) { + super(message); + this.code = code; + } +} + +export class ConnectionLostError extends ElementCallError { + public constructor() { + super("Connection lost", ErrorCode.CONNECTION_LOST_ERROR); + } +}