UNPKG

@telnyx/webrtc

Version:
63 lines (62 loc) 2.72 kB
import { SDK_ERRORS, SdkErrorCode } from './constants/errors'; import { SDK_WARNINGS, SdkWarningCode, ITelnyxWarning, createTelnyxWarning } from './constants/warnings'; import { MEDIA_MICROPHONE_PERMISSION_DENIED, MEDIA_DEVICE_NOT_FOUND, MEDIA_GET_USER_MEDIA_FAILED } from './constants/errorCodes'; export { SDK_ERRORS, SdkErrorCode }; export { SDK_WARNINGS, SdkWarningCode, ITelnyxWarning, createTelnyxWarning }; export declare type TelnyxMediaErrorCode = typeof MEDIA_MICROPHONE_PERMISSION_DENIED | typeof MEDIA_DEVICE_NOT_FOUND | typeof MEDIA_GET_USER_MEDIA_FAILED; export interface ITelnyxError { code: SdkErrorCode; name: string; description: string; message: string; causes: string[]; solutions: string[]; originalError?: unknown; fatal: boolean; } export interface ITelnyxMediaError extends Omit<ITelnyxError, 'code'> { code: TelnyxMediaErrorCode; } export interface ITelnyxStandardErrorEvent { error: ITelnyxError; sessionId: string; callId?: string; recoverable?: false; } export interface ITelnyxMediaRecoveryErrorEvent { error: ITelnyxMediaError; sessionId: string; callId: string; recoverable: true; retryDeadline: number; resume: () => void; reject: () => void; } export declare type ITelnyxErrorEvent = ITelnyxStandardErrorEvent | ITelnyxMediaRecoveryErrorEvent; export declare class TelnyxError extends Error implements ITelnyxError { readonly code: SdkErrorCode; readonly description: string; readonly causes: string[]; readonly solutions: string[]; readonly originalError?: unknown; readonly fatal: boolean; constructor(params: Omit<ITelnyxError, 'message'> & { message?: string; }); toJSON(): ITelnyxError; } export declare function isMediaRecoveryErrorEvent(event: ITelnyxErrorEvent): event is ITelnyxMediaRecoveryErrorEvent; export declare function classifyMediaErrorCode(error: unknown): typeof MEDIA_MICROPHONE_PERMISSION_DENIED | typeof MEDIA_DEVICE_NOT_FOUND | typeof MEDIA_GET_USER_MEDIA_FAILED; export declare function createTelnyxError(code: SdkErrorCode, originalError?: unknown, message?: string, fatal?: boolean): TelnyxError; export declare class RequestTimeoutError extends Error { readonly requestId: string; readonly timeoutMs: number; readonly method: string; constructor(requestId: string, timeoutMs: number, method?: string); } export declare class StaleRequestError extends Error { readonly requestId: string; readonly staleGeneration: number; readonly currentGeneration: number; constructor(requestId: string, staleGeneration: number, currentGeneration: number); }