Skip to main content
Version: 5.x.x

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 3055 or 4002. 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) and UNAUTHORIZED_PARTCIPANT_ID (4023).

message​

  • type: String
  • A description of the error. The server can replace it with its own text, so check code or name in your code, not message.

Common codes​

CodeNameMeaning
3035ERROR_ACTION_PERFORMED_BEFORE_ROOM_JOINEDThe action needs a joined room, or the room has already left.
3054ERROR_ALREADY_IN_REQUESTED_STATEThere is nothing to do, for example leave() after the room has left.
3055ERROR_OPERATION_IN_PROGRESSThe same action is still running, for example after a double tap.
3065ERROR_ROOM_RECONNECTINGThe room is reconnecting. Try again once it has reconnected.
3073ERROR_INVALID_PARAMETERAn argument is not valid, for example an empty room id.
4000UNKNOWN_ERRORThe SDK could not classify the failure. message keeps the original text.
4002INVALID_TOKENThe 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:

  • PubSub and RealtimeStore calls made before the room is joined throw a VideoSDKError with code 3035.
  • room.send() throws an ArgumentError for a message that is not a String or a List<int>.
  • The pre-call test fails with a PreCallTestException, whose code is a String.

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