Search Overlay

Error Handling



The SDK provides a unified approach to handling errors by throwing a WalletException/WalletError object as a response whenever an error is returned by the Paysafe Wallet SDK.

Android iOS Description
WalletException WalletError The base exception type in Android. The error enum in iOS
NotConfiguredException .notConfigured The configure() method has not been called
DataException .dataError API call data-related issue with provided ErrorDetails
InternalErrorException .internalError Internal SDK error with specific reason
ServiceUnavailableException .serviceUnavailable Paysafe backend is temporary unavailable
TokenExpiredException .tokenExpired Access token has expired


Every DataException/.dataError object has additional information about the specific API error.

Field Description
httpStatus The HTTP status code
code Specific Paysafe error code
message Description of the error
details Details of any parameter value errors
fieldErrors List of field with errors

Handling errors on Android

The errors on Android are represented by standard exceptions extended from WalletException class. Surround any SDK operation in runCatching with onSuccess and onFailure:

runCatching {
}.onSuccess { customerInfo ->
    Log.d(TAG, customerInfo.toString())
}.onFailure { exception ->
    Log.d(TAG, exception.toString())

Try-catch blocks can also be used:

try {
    val customerInfo = userService.getProfile(listOf(ProfileIncludes.ACCOUNTS))
    Log.d(TAG, customerInfo.toString())
} catch (exception: WalletException){
    Log.d(TAG, exception.toString())

Handling errors on iOS

The errors on iOS are represented by the WalletError enum. Every SDK operation includes completion handler with .failure case containing the specific error:

profile.getProfile(include: [.contactInfo], completion: { result in
    switch result {
    case .success(let customerInfo):
        // Display customer information
    case .failure(let error):
        // Handle error
On this Page