/** * @file RTCError - WebRTC-specific error types. * * Implements the W3C RTCError interface * (https://www.w3.org/TR/webrtc/#rtcerror-interface). * * Provides WebRTC-specific error types extending the standard Error class * with additional error detail types and metadata fields. * * @license MIT * @author nmhung1210 */ /** * RTCErrorDetailType enum - Standardized WebRTC error details. * Maps to RTCErrorDetailType from the WebRTC spec. * * @readonly * @enum {string} */ declare const RTCErrorDetailType: Readonly<{ readonly NONE: "none"; readonly DATA_CHANNEL_FAILURE: "data-channel-failure"; readonly DTLS_FAILURE: "dtls-failure"; readonly FINGERPRINT_FAILURE: "fingerprint-failure"; readonly SCTP_FAILURE: "sctp-failure"; readonly SDP_SYNTAX_ERROR: "sdp-syntax-error"; readonly HARDWARE_ENCODER_NOT_AVAILABLE: "hardware-encoder-not-available"; readonly HARDWARE_ENCODER_ERROR: "hardware-encoder-error"; readonly INVALID_STATE: "invalid-state"; readonly INVALID_MODIFICATION: "invalid-modification"; readonly INVALID_ACCESS_ERROR: "invalid-access-error"; readonly OPERATION_ERROR: "operation-error"; }>; /** * Error detail type string union. */ type RTCErrorDetail = typeof RTCErrorDetailType[keyof typeof RTCErrorDetailType]; /** * Error initialization dictionary. */ interface RTCErrorInit { errorDetail?: string; sdpLineNumber?: number | null; httpRequestStatusCode?: number | null; sctpCauseCode?: number | null; receivedAlert?: number | null; sentAlert?: number | null; } /** * Native WebRTC error object shape. */ interface NativeRTCError { error_detail?: string; sctp_cause_code?: number; message?: string; } /** * JSON representation of an RTCError. */ interface RTCErrorJSON { name: string; message: string; errorDetail: string; sdpLineNumber?: number; httpRequestStatusCode?: number; sctpCauseCode?: number; receivedAlert?: number; sentAlert?: number; } /** * RTCError extends Error with WebRTC-specific error details. * * @extends Error */ declare class RTCError extends Error { #private; /** Export error detail types as static property */ static readonly DetailType: Readonly<{ readonly NONE: "none"; readonly DATA_CHANNEL_FAILURE: "data-channel-failure"; readonly DTLS_FAILURE: "dtls-failure"; readonly FINGERPRINT_FAILURE: "fingerprint-failure"; readonly SCTP_FAILURE: "sctp-failure"; readonly SDP_SYNTAX_ERROR: "sdp-syntax-error"; readonly HARDWARE_ENCODER_NOT_AVAILABLE: "hardware-encoder-not-available"; readonly HARDWARE_ENCODER_ERROR: "hardware-encoder-error"; readonly INVALID_STATE: "invalid-state"; readonly INVALID_MODIFICATION: "invalid-modification"; readonly INVALID_ACCESS_ERROR: "invalid-access-error"; readonly OPERATION_ERROR: "operation-error"; }>; /** * Creates a new RTCError. * * @param {RTCErrorInit} [init={}] - Error initialization dictionary * @param {string} [init.errorDetail='none'] - Error detail type * @param {number} [init.sdpLineNumber] - SDP line number where error occurred * @param {number} [init.httpRequestStatusCode] - HTTP status code if relevant * @param {number} [init.sctpCauseCode] - SCTP cause code * @param {number} [init.receivedAlert] - TLS alert received * @param {number} [init.sentAlert] - TLS alert sent * @param {string} [message=''] - Error message */ constructor(init?: RTCErrorInit, message?: string); /** * RTCErrorDetailType - specific error category. * @type {string} */ get errorDetail(): string; /** * SDP line number where the error occurred (if applicable). * @type {number|null} */ get sdpLineNumber(): number | null; /** * HTTP request status code (if applicable). * @type {number|null} */ get httpRequestStatusCode(): number | null; /** * SCTP cause code (if applicable). * @type {number|null} */ get sctpCauseCode(): number | null; /** * TLS alert value received (if applicable). * @type {number|null} */ get receivedAlert(): number | null; /** * TLS alert value sent (if applicable). * @type {number|null} */ get sentAlert(): number | null; /** * Converts error to JSON representation. * @returns {Object} JSON representation of the error */ toJSON(): RTCErrorJSON; /** * Creates RTCError from a native WebRTC error object. * @param {Object} nativeError - Native error object * @param {string} [nativeError.error_detail] - Error detail type * @param {number} [nativeError.sctp_cause_code] - SCTP cause code * @param {string} [nativeError.message] - Error message * @returns {RTCError} */ static fromNative(nativeError: NativeRTCError): RTCError; } export default RTCError; export { RTCError, RTCErrorDetailType }; export type { RTCErrorInit, RTCErrorDetail, NativeRTCError, RTCErrorJSON };