Skip to content

Error Callbacks

Partners can subscribe to be notified of error events that occur within the SDK. The errors returned are specific to failures that partners have control over, such as issues with auth tokens. These events are intended to be used for debugging or analytic purposes, and should not be used to change the user experience as the display of error messaging is handled by the SDK.

Partners should implement the DoshErrorDelegate protocol to receive the error events from the SDK.

1
2
3
4
5
Dosh.instance?.errorDelegate = self

func errorOccurred(in dosh: Dosh, error: DoshSDKError) {
    print("Received error from Dosh SDK. Localized description: \(error.localizedDescription) --- failure reason: \(String(describing: error.failureReason))")
}

Partners should implement the DoshErrorListener interface to receive the error events from the SDK.

1
2
3
4
5
6
7
8
9
PoweredByDosh.instance?.errorListener = this

override fun onErrorOccurred(exception: DoshException) {
    if (exception is DoshException.NetworkError) {
        Log.e("DOSH-ERROR", exception.message, exception.cause)
    } else {
        Log.e("DOSH-ERROR", exception.message ?: "")
    }
}