feat(errors): Report livekit as such rather than like unknown errors

This commit is contained in:
Valere
2026-06-04 11:54:42 +02:00
parent 5f257da4f6
commit e7d37f87bb
6 changed files with 1897 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ Please see LICENSE in the repository root for full details.
*/
import { t } from "i18next";
import { type ConnectionError } from "livekit-client";
export enum ErrorCode {
/**
@@ -43,6 +44,10 @@ export class ElementCallError extends Error {
public localisedMessage?: string;
public localisedTitle: string;
// Alternative to localisedMessage, for rich error rendering
public localisedMessageKey?: string;
public localisedMessageValues?: Record<string, string>;
protected constructor(
localisedTitle: string,
code: ErrorCode,
@@ -235,3 +240,33 @@ export class SFURoomCreationRestrictedError extends ElementCallError {
);
}
}
/**
* Error indicating that the SFU peer-to-peer connection timed out.
*/
export class PeerConnectionTimeoutError extends ElementCallError {
public constructor() {
super(
t("error.peer_connection_timeout"),
ErrorCode.SFU_ERROR,
ErrorCategory.NETWORK_CONNECTIVITY,
);
this.localisedMessageKey = "error.peer_connection_timeout_description";
this.localisedMessageValues = {
linkUrl:
"https://docs.element.io/latest/element-server-suite-pro/configuring-components/configuring-matrix-rtc/#sfu-connectivity-troubleshooting",
};
}
}
export class LivekitConnectionError extends ElementCallError {
public constructor(cause: ConnectionError) {
super(
t("error.livekit_connection_error"),
ErrorCode.SFU_ERROR,
ErrorCategory.NETWORK_CONNECTIVITY,
);
this.localisedMessageKey = "error.livekit_connection_error_description";
this.localisedMessageValues = { reason: cause.reasonName };
}
}