The Error class is used to define the error object passed into completion handlers.
Each of the following methods, which execute asynchronously, includes a
completionHandler parameter:
- OT.initPublisher()
- OT.reportIssue()
- OT.setProxyUrl()
- Publisher.setVideoSource()
- Session.connect()
- Session.forceDisconnect()
- Session.forceUnpublish()
- Session.publish()
- Session.subscribe()
- Subscriber.getStats()
The Error class also defines the Error thrown when the promise returned by one of the following methods is rejected:
- OT.unblockAudio()
- Publisher.applyVideoFilter()
- Publisher.clearVideoFilter()
- Publisher.applyAudioFilter()
- Publisher.clearAudioFilter()
- Publisher.getRtcStatsReport()
- Session.forceMuteAll()
- Session.forceMuteStream()
- Session.setEncryptionSecret()
- Subscriber.getRtcStatsReport()
The completionHandler parameter is a function that is called when the call to
the asynchronous method succeeds or fails. If the asynchronous call fails, the completion
handler function is passed an error object (defined by the Error class). The code
and message properties of the error object provide details about the error.
Deprecation notice: OT.Error will not be defined in an upcoming version of Vonage Video API. When this happens,
errors emitted by the SDK will simply be instances of standard Error objects.
If your code currently checks if (error instanceof OT.Error) please replace it
if (/^OT_/.test(error.name)). (The name property for all Vonage Video API
errors with begins with 'OT_'.) Note however that this code is for the
purposes of smoothly upgrading, and it may be more appropriate for your code to simply compare
against the specific error you want to handle, such as
if (error.name === 'OT_USER_MEDIA_ACCESS_DENIED').
Properties
| Name | Type | Description |
|---|---|---|
code | Number | Deprecated — the error code. Use the name property, not the code property, to identify the error programatically. The code property of the Error object can be set to one of the values listed below. This property can also be set to other values, and you may want to report this value when discussing an issue with Vonage API support. Errors when calling Session.connect(): |
message | String | The message string provides details about the error. Use the name property (not the message property) to identify the error programatically. |
name | String | A string identifying the error. Use this property (not the code property) to identify the error. Note that for all errors, this string starts with 'OT_'. The name property of the Error object can be set to one of the values listed below. For unexpected errors, this property can be undefined or set to other values. You may want to report this value when discussing an issue with Vonage API support. Errors that can occur when calling OT.initPublisher(): |
Methods
| Name | Description |
|---|---|
isDefaultPrevented() → {Boolean} | Whether the default event behavior has been prevented via a call to preventDefault() (true) or not (false). |
preventDefault() | Prevents the default behavior associated with the event from taking place. |
isDefaultPrevented() → {Boolean}
Whether the default event behavior has been prevented via a call to
preventDefault() (true) or not (false).
See preventDefault().
Returns:
preventDefault()
Prevents the default behavior associated with the event from taking place.
To see whether an event has a default behavior, check the cancelable property
of the event object.
Call the preventDefault() method in the callback function for the event.
The following events have default behaviors:
sessionDisconnect— See SessionDisconnectEvent.preventDefault().streamDestroyed— See StreamEvent.preventDefault().accessDialogOpened— See the accessDialogOpened event.accessDenied— See the accessDenied event.