Exceptions

Exceptions raised by WebRTC operations.

Errors of the specifications are subclasses of RTCException, named after the DOMException names, so an InvalidStateError is caught with except webrtc.InvalidStateError. The SyntaxError and RangeError of the specifications are InvalidSyntaxError and InvalidRangeError, which don’t shadow the Python builtins and are ValueError subclasses too.

webrtc.exceptions.PythonWebRTCExceptionBase

The root of every exception of the native module, PythonWebRTCException

webrtc.exceptions.PythonWebRTCException

The native exception that RTCException subclasses, and so every WebRTC error of this library does too

class webrtc.exceptions.RTCException(*args, **kwargs)

The base class of the WebRTC errors. It stands for the DOMException of the specifications.

Errors of the native WebRTC engine are raised as the subclass that matches their type. Catch this class to handle any of them.

See MDN: DOMException.

Return type:

Any

property message: str

The description of the error. It’s the first argument, or an empty string without one.

See MDN: DOMException/message.

Type:

str

class webrtc.exceptions.InvalidStateError(*args, **kwargs)

The object’s state doesn’t allow the operation, like calling a method of a closed connection.

Return type:

Any

class webrtc.exceptions.InvalidAccessError(*args, **kwargs)

The object doesn’t support the parameter or the operation, like a description it can’t apply.

Return type:

Any

class webrtc.exceptions.InvalidModificationError(*args, **kwargs)

The change isn’t allowed, like a change to a read-only member of the parameters of a sender.

Return type:

Any

class webrtc.exceptions.OperationError(*args, **kwargs)

The operation failed for a reason specific to it.

Errors of the native WebRTC engine without a closer match are raised as this class.

Return type:

Any

class webrtc.exceptions.NotSupportedError(*args, **kwargs)

This library or the native WebRTC engine doesn’t support the operation or the value.

Return type:

Any

class webrtc.exceptions.NetworkError(*args, **kwargs)

A network protocol below the operation failed.

Return type:

Any

class webrtc.exceptions.NotFoundError(*args, **kwargs)

The object asked for doesn’t exist, like a simulcast layer of an unknown rid.

Return type:

Any

class webrtc.exceptions.NotAllowedError(*args, **kwargs)

The operation isn’t allowed with these arguments, like a malformed rid.

Return type:

Any

class webrtc.exceptions.DataCloneError(*args, **kwargs)

An object can’t be cloned or transferred, like a buffer listed twice in transfer.

Return type:

Any

exception webrtc.exceptions.InvalidSyntaxError(*args, **kwargs)

A string doesn’t parse, like an ICE server URL. It stands for the SyntaxError of the specifications.

Return type:

Any

exception webrtc.exceptions.InvalidRangeError(*args, **kwargs)

A value is out of its allowed range. It stands for the RangeError of the specifications.

Return type:

Any

exception webrtc.exceptions.InvalidCharacterError(*args, **kwargs)

A string has a character that isn’t allowed, like a DTMF tone that doesn’t exist.

Return type:

Any

class webrtc.exceptions.OverconstrainedError(*args, **kwargs)

No source can satisfy a required constraint of a track.

See MDN: OverconstrainedError.

Parameters:
  • constraint (str) – The name of the constraint, like 'width'.

  • message (str, optional) – The description of the error. Defaults to one naming the constraint.

constraint

The name of the constraint that can’t be satisfied. See MDN: OverconstrainedError/constraint.

Type:

str

class webrtc.exceptions.RTCErrorInit(error_detail, sdp_line_number=None, sctp_cause_code=None, received_alert=None, sent_alert=None, http_request_status_code=None)

The WebRTC-specific members of an RTCError.

See MDN: RTCError/RTCError.

Parameters:
  • error_detail (webrtc.RTCErrorDetailType) – The cause of the error, as a member or its string value.

  • sdp_line_number (int, optional) – The line of the SDP that doesn’t parse.

  • sctp_cause_code (int, optional) – The SCTP cause code of a failed data channel or association.

  • received_alert (int, optional) – The DTLS alert received from the remote peer.

  • sent_alert (int, optional) – The DTLS alert sent to the remote peer.

  • http_request_status_code (int, optional) – The HTTP status code of a failed request.

Raises:

ValueError – If error_detail isn’t a member of webrtc.RTCErrorDetailType.

class webrtc.exceptions.RTCError(*args, **kwargs)

An OperationError with WebRTC-specific members, copied from its RTCErrorInit.

It’s raised for errors of the native WebRTC engine that carry a detail, like a description that doesn’t parse. The error events of data channels and transports carry it too.

See MDN: RTCError.

Parameters:
  • init (RTCErrorInit) – The WebRTC-specific members.

  • message (str, optional) – The description of the error.

error_detail

The cause of the error. See MDN: RTCError/errorDetail.

Type:

webrtc.RTCErrorDetailType

sdp_line_number

The line of the SDP that doesn’t parse. See MDN: RTCError/sdpLineNumber.

Type:

int, optional

sctp_cause_code

The SCTP cause code of a failed data channel or association. See MDN: RTCError/sctpCauseCode.

Type:

int, optional

received_alert

The DTLS alert received from the remote peer. See MDN: RTCError/receivedAlert.

Type:

int, optional

sent_alert

The DTLS alert sent to the remote peer. See MDN: RTCError/sentAlert.

Type:

int, optional

http_request_status_code

The HTTP status code of a failed request.

Type:

int, optional