VideoSDKError Class - Flutter
VideoSDKError is the exception that the SDK throws when an action fails. Room, Participant and RTCStream actions, such as room.join(), room.unmuteMic() or participant.pin(), return a Future that throws it. VideoSDK.createCameraVideoTrack(), VideoSDK.createMicrophoneAudioTrack() and VideoSDK.createScreenShareVideoTrack() throw it too.
The Room's error event delivers a VideoSDKError too. Await each action inside try/catch. A call you do not await turns a failure into an unhandled async error.
To learn how to handle these errors in your app, see the Error Handling guide.
Properties
code
- type:
int - The error code, for example
3055or4002. Room Error Codes lists every code.
name
- type:
String - The name of the error, for example
ERROR_OPERATION_IN_PROGRESS. - Names keep the spelling of the error catalogue, including
MAX_PARTCIPANT_REACHED(4009) andUNAUTHORIZED_PARTCIPANT_ID(4023).
message
- type:
String - A description of the error. The server can replace it with its own text, so check
codeornamein your code, notmessage.
Common codes
| Code | Name | Meaning |
|---|---|---|
| 3035 | ERROR_ACTION_PERFORMED_BEFORE_ROOM_JOINED | The action needs a joined room, or the room has already left. |
| 3054 | ERROR_ALREADY_IN_REQUESTED_STATE | There is nothing to do, for example leave() after the room has left. |
| 3055 | ERROR_OPERATION_IN_PROGRESS | The same action is still running, for example after a double tap. |
| 3065 | ERROR_ROOM_RECONNECTING | The room is reconnecting. Try again once it has reconnected. |
| 3073 | ERROR_INVALID_PARAMETER | An argument is not valid, for example an empty room id. |
| 4000 | UNKNOWN_ERROR | The SDK could not classify the failure. message keeps the original text. |
| 4002 | INVALID_TOKEN | The token was rejected. |
Most Room actions called before the first room.join() throw 4000. After room.leave(), they throw 3035, and leave() itself throws 3054. join() on a room that has left throws a StateError.
Other exceptions
Some calls throw other exceptions:
PubSubandRealtimeStorecalls made before the room is joined throw aVideoSDKErrorwith code3035.room.send()throws anArgumentErrorfor a message that is not aStringor aList<int>.- The pre-call test fails with a
PreCallTestException, whosecodeis aString.
Every catalogue error is also a constant on VideoSDKError, such as VideoSDKError.ERROR_ROOM_RECONNECTING. Errors are equal when their code is equal, so you can compare with ==:
try {
await room.enableCam();
} on VideoSDKError catch (error) {
if (error == VideoSDKError.ERROR_ROOM_RECONNECTING) {
// try again once the room reconnects
}
}
Example
try {
await room.join();
} on VideoSDKError catch (error) {
if (error.code == 4002) {
// The token was rejected. Get a new one from your server.
}
print("Join failed: ${error.code} ${error.name}: ${error.message}");
}
Got a Question? Ask us on discord

