0.3.x to 0.4.x Migration Guide

Error Type Changes

The error type in the public SDK interface has been changed to Error (NSError in case of ObjC) from HMSError. This is to align with platform conventions. In swift the error can be type casted to either HMSError or NSError for getting additional details like error code.

Error Handling Example

func on(error: Error) { guard let error = error as? HMSError else { return } //Example using error constants switch error.code { case .websocketConnectionLost, .iceFailure, .endpointUnreachable: retryConnection() default: showErrorAndExitMeeting(errorMessage: error.localizedDescription) break } //Example using error codes switch error.code.rawValue { case 1003, 4005, 2003: retryConnection() default: showErrorAndExitMeeting(errorMessage: error.localizedDescription) break } }

Error Property Changes

isTerminal

The HMSError struct in swift will now have an isTerminal property which denotes wether error has caused the current session to terminate and the app will need to call join again to reconnect. Same will be available via is_terminal (HMSIsTerminalUserInfoKey constant) key in userInfo dictionary of NSError

canRetry

The HMSError struct in swift will now have an canRetry property which denotes wether app can call join again with the same configuration it has used before. The value be false in cases like token expiring or room getting locked. You can use this property while implementing infinite retry in your app. Same will be available via can_retry (HMSCanRetryUserInfoKey constant) key in userInfo dictionary of NSError

Removed properties

Error properties: id, action, info, message, params have been removed. localizedDescription property will contain all the necessary info.

Error Handling Example Using Properties

This example shows the minimal error handling you can have in the app without worrying about error codes.

func on(error: Error) { guard let error = error as? HMSError else { return } if error.isTerminal { if error.canRetry && isInfiniteRetryEnabledInApp { retryConnection() } else { showErrorAndExitMeeting(errorMessage: error.localizedDescription) } } else { logError(message: error.localizedDescription) } }

Error Code Changes

Previously upon loosing connection and failing to reconnect as well as in case initial connection could not be established SDK would return error code 2000 (initServerError). Starting from 0.4.1 SDK will return error 1003 (websocketConnectionLost) if the connection was previously there but got lost in the middle of the session. If the SDK can not connect in the first place it will return error code 2003 (endpointUnreachable). This change makes error codes consistent between platforms

Error Constant Name Changes

CodeOld NameNew Name
2002initHTTPErrorInvalidEndpointURLinvalidEndpointUrl
2003initHTTPErrorEndpointUnreachableendpointUnreachable
3000tracksErrorGenericgenericTrack
3001tracksErrorCantAccessCaptureDevicecantAccessCaptureDevice
3005tracksErrorNothingToReturnnothingToReturn
3007tracksErrorCodecChangeNotPermittedcodecChangeNotPermitted
3008tracksErrorAudioVideoSubsystemFailureaudiovideoSubsystemFailure
3011tracksErrorMicCaptureFailedmicCaptureFailed
4001webrtcErrorCreateOfferFailedcreateOfferFailed
4002webrtcErrorCreateAnswerFailedcreateAnswerFailed
4003webrtcErrorSetLocalDescriptionFailedsetLocalDescriptionFailed
4004webrtcErrorSetRemoteDescriptionFailedsetRemoteDescriptionFailed
4005webrtcErrorICEFailureiceFailure
5001joinErrorAlreadyJoinedalreadyJoined
6000genericErrorNotConnectednotConnected
6002genericErrorUnknownunknown
6004genericErrorJsonParsingFailedjsonParsingFailed

Have a suggestion? Recommend changes ->

Was this helpful?

1234