# Exceptions

Exceptions raised by WebRTC operations.

Errors of the specifications are subclasses of [`RTCException`](#webrtc.exceptions.RTCException), named after the `DOMException` names, so an
`InvalidStateError` is caught with `except webrtc.InvalidStateError`. The `SyntaxError` and `RangeError` of the
specifications are [`InvalidSyntaxError`](#webrtc.exceptions.InvalidSyntaxError) and [`InvalidRangeError`](#webrtc.exceptions.InvalidRangeError), which don’t shadow the Python builtins and
are [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError) subclasses too.

### webrtc.exceptions.PythonWebRTCExceptionBase

The root of every exception of the native module, [`PythonWebRTCException`](#webrtc.exceptions.PythonWebRTCException)

### webrtc.exceptions.PythonWebRTCException

The native exception that [`RTCException`](#webrtc.exceptions.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](https://developer.mozilla.org/en-US/docs/Web/API/DOMException).

* **Return type:**
  Any

#### *property* message *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)*

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

See [MDN: DOMException/message](https://developer.mozilla.org/en-US/docs/Web/API/DOMException/message).

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#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](https://developer.mozilla.org/en-US/docs/Web/API/OverconstrainedError).

* **Parameters:**
  * **constraint** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – The name of the constraint, like `'width'`.
  * **message** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#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](https://developer.mozilla.org/en-US/docs/Web/API/OverconstrainedError/constraint).

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#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`](#webrtc.exceptions.RTCError).

See [MDN: RTCError/RTCError](https://developer.mozilla.org/en-US/docs/Web/API/RTCError/RTCError).

* **Parameters:**
  * **error_detail** ([`webrtc.RTCErrorDetailType`](enums.md#webrtc.enums.RTCErrorDetailType)) – The cause of the error, as a member or its string value.
  * **sdp_line_number** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The line of the SDP that doesn’t parse.
  * **sctp_cause_code** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The SCTP cause code of a failed data channel or association.
  * **received_alert** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The DTLS alert received from the remote peer.
  * **sent_alert** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The DTLS alert sent to the remote peer.
  * **http_request_status_code** ([`int`](https://docs.python.org/3/builtins/functions.html#int), optional) – The HTTP status code of a failed request.
* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If `error_detail` isn’t a member of [`webrtc.RTCErrorDetailType`](enums.md#webrtc.enums.RTCErrorDetailType).

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

An [`OperationError`](#webrtc.exceptions.OperationError) with WebRTC-specific members, copied from its [`RTCErrorInit`](#webrtc.exceptions.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](https://developer.mozilla.org/en-US/docs/Web/API/RTCError).

* **Parameters:**
  * **init** ([`RTCErrorInit`](#webrtc.exceptions.RTCErrorInit)) – The WebRTC-specific members.
  * **message** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The description of the error.

#### error_detail

The cause of the error. See [MDN: RTCError/errorDetail](https://developer.mozilla.org/en-US/docs/Web/API/RTCError/errorDetail).

* **Type:**
  [`webrtc.RTCErrorDetailType`](enums.md#webrtc.enums.RTCErrorDetailType)

#### sdp_line_number

The line of the SDP that doesn’t parse.
See [MDN: RTCError/sdpLineNumber](https://developer.mozilla.org/en-US/docs/Web/API/RTCError/sdpLineNumber).

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int), optional

#### sctp_cause_code

The SCTP cause code of a failed data channel or association.
See [MDN: RTCError/sctpCauseCode](https://developer.mozilla.org/en-US/docs/Web/API/RTCError/sctpCauseCode).

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int), optional

#### received_alert

The DTLS alert received from the remote peer.
See [MDN: RTCError/receivedAlert](https://developer.mozilla.org/en-US/docs/Web/API/RTCError/receivedAlert).

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int), optional

#### sent_alert

The DTLS alert sent to the remote peer. See [MDN: RTCError/sentAlert](https://developer.mozilla.org/en-US/docs/Web/API/RTCError/sentAlert).

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int), optional

#### http_request_status_code

The HTTP status code of a failed request.

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int), optional
