Errors (iOS SDK)
The iOS SDK may return various errors. These can be caught via the createPlayer() method and DMPlayerDelegate's didFail delegate errors.
Error types
| Error | Error description |
|---|---|
PlayerError.underlyingRemoteError(error: Error) | Triggered by the embed Player and forwarded by the SDK. Details about possible video access error is documented here. |
PlayerError.advertisingModuleMissing | Triggered by the SDK when the advertising module is missing. Please add it, otherwise the Player will not run |
PlayerError.playerIdNotFound | Triggered by the SDK when the Player ID cannot be found |
PlayerError.stateNotAvailable | Triggered by the SDK when asking the Player for current state, but state is not available at that time |
PlayerError.internetNotConnected | Player request failed since the internet seems offline - Retry the call |
PlayerError.requestTimedOut | Player request took longer than expected - Retry the call |
PlayerError.otherPlayerRequestError | Other Player request related error - Check the logs for more info |
PlayerError.unexpected | Triggered when something went wrong and an unexpected error has occurred - Check the logs for more info - If it persists, contact support |
Handling errors
PlayerError implements swift Error protocol and can be safely casted to NSError if needed.
Exemple:
func handlePlayerError(error: Error) {
switch(error) {
case PlayerError.advertisingModuleMissing :
break;
case PlayerError.stateNotAvailable :
break;
case PlayerError.underlyingRemoteError(error: let error):
let error = error as NSError
if let errDescription = error.userInfo[NSLocalizedDescriptionKey],
let errCode = error.userInfo[NSLocalizedFailureReasonErrorKey],
let recovery = error.userInfo[NSLocalizedRecoverySuggestionErrorKey] {
print("Player Error : Description: \(errDescription), Code: \(errCode), Recovery : \(recovery) ")
} else {
print("Player Error : \(error)")
}
break
case PlayerError.requestTimedOut:
print(error.localizedDescription)
break
case PlayerError.unexpected:
print(error.localizedDescription)
break
case PlayerError.internetNotConnected:
print(error.localizedDescription)
break
case PlayerError.playerIdNotFound:
print(error.localizedDescription)
break
case PlayerError.otherPlayerRequestError:
print(error.localizedDescription)
break
default:
print(error.localizedDescription)
break
}
}Updated 5 months ago
