Error Details
This topic provides the SDK error details.
Netspend exposes the following errors.
Error | Description |
---|---|
DecryptFailure | Web SDK is not able to decrypt the provided input. |
DeviceDataGenerationFailure | May occur if an Iovation connection failure occurs. |
DeviceKeyGenerationFailure | Web SDK is not able to generate its key pairs. |
EncryptFailure | Web SDK is not able to encrypt the provided input. |
InvalidUserSessionInitializationData | The user_session_initialization_data provided in web SDK is invalid. |
SecureStorageFailure | May occur during operations at a storage level. |
UserSessionConnectionFailure | May occur while creating a user session (key exchange process) in web SDK. |
Code Samples for Error Catching
Below are the code samples for error catching for Web SDK, Android SDK, and iOS SDK.
Web SDK
try {
// `user_session_initialization_data` from your server
const init = await
NetspendSDK.session.initialize(userSessionInitializationData);
NetspendSDK.session.state // 'initializing'
// Send `init.deviceData` to your server to create a user session
// Then, from the response of creating the user session on the server
//
// const response = await fetch('/sessions', { body:init.deviceData }});
// const sessionData = await response.json();
//
// Pass the "encrypted_data" from POST /sessions to init.open()
// to finish opening the session
await init.open(sessionData.encrypted_data);
NetspendSDK.session.state // 'ready'
NetspendSDK.session.sessionId // Session ID, e.g. '3b10acea-e862-4720-91e0-fdd80a13eb28'
// Now you can use the "encrypt()" and "decrypt()" methods
}
catch(error){
// Failure! error.code will contain the above mentioned error codes
if(error.code === 'InvalidUserSessionInitializationData') {
alert('Invalid user session data has been passed to websdk');
}
}
Android SDK
You can catch fatal errors by overriding onNetspendSdkEncounteredFatalError(errorMessage: String)
in your NetspendSdkActivity
subclass. The default implementation is to log the message to stderr
and then kill the entire application process.
class MyNetspendSdkActivity : NetspendSdkActivity() {
override fun onNetspendSdkEncounteredFatalError(errorMessage: String) {
System.err.println("Uh oh. Netspend had a fatal error. We should indicate to the user that all netspend sdk is unavailable.")
System.err.println(errorMessage)
// Finish, to go back to the prior screen because this Activity will *not* work in its current state
finish()
// Defaults to killing your process, which crashes your app
// android.os.Process.killProcess(android.os.Process.myPid());
}
}
iOS SDK
You can catch fatal errors by implementing the delegate NetspendSdkViewControllerDelegate
.
extension MyNetspendDelegate: NetspendSdkViewControllerDelegate {
func netspendSdkViewController(_ viewController: NetspendSdkViewController,
didEncounterFatalError errorMessage: String) {
print("Uh oh. Netspend had a fatal error.
We should indicate to the user that all netspend sdk is unavailable.")
print(errorMessage)
// Defaults to `fatalError`, which crashes your app
// fatalError(errorMessage)
}
}
Updated about 1 year ago