Error handling
In this document you can find a description of all errors that can occur in the Flutter Plugin and details on how they should be handled.
Error codes
Every error object has a unique code that identifies the error. Some plugin errors occur on both the iOS and Android implementation, while others can only occur on a specific platform.
As the Flutter Plugin is a wrapper for the Android and iOS SDKs, many errors that are returned come directly from the SDKs themselves. This is true for error codes in the ranges 9000 and higher.
These error codes are mostly consistent. However, there may be some small differences between the two platforms. See the error handling documentation for the Android SDK and the iOS SDK for details. Both sets of documentation also include an error map at the bottom of the page.
The errors specific to the Flutter Plugin that occur on iOS and Android are:
Error Code | Category |
---|---|
8000 | GENERIC ERROR |
8040 | NOT AUTHENTICATED USER |
8041 | NOT AUTHENTICATED IMPLICIT |
8042 | NOT FOUND USER PROFILE |
8043 | NOT FOUND AUTHENTICATOR |
8044 | NOT FOUND IDENTITY PROVIDER |
8046 | HTTP REQUEST ERROR INTERNAL |
8047 | HTTP REQUEST ERROR CODE |
8050 | INVALID URL |
8051 | NOT IN PROGRESS CUSTOM REGISTRATION |
8052 | NOT IN PROGRESS AUTHENTICATION |
8053 | NOT IN PROGRESS OTP AUTHENTICATION |
8054 | NOT IN PROGRESS PIN CREATION |
8057 | ACTION NOT ALLOWED CUSTOM REGISTRATION CANCEL |
8058 | ACTION NOT ALLOWED BROWSER REGISTRATION CANCEL |
8059 | CONFIG ERROR |
8060 | BIOMETRIC AUTHENTICATION NOT AVAILABLE |
As the OneWelcome Flutter plugin is a wrapper for the Android and iOS SDKs, many errors that are returned come directly from the SDKs themselves. This is true for error codes in the ranges 9000 and higher.
iOS error codes
The errors specific to the Flutter Plugin that occur only on iOS are:
Error Code | Category |
---|---|
8048 | HTTP REQUEST NO RESPONSE |
8056 | ALREADY IN PROGRESS MOBILE AUTHENTICATION |
Android error codes
The errors specific to the Flutter Plugin that occur only on Android are:
Error Code | Category |
---|---|
8045 | NOT FOUND SECURITY CONTROLLER |
8049 | NOT INITIALIZED ONEWELCOME SDK |
8055 | NOT IN PROGRESS FINGERPRINT AUTHENTICATION |
Platform exception
As mentioned previously, many of the errors that are thrown will be errors that originate from our native SDKs because we are dealing with a wrapper plugin. These errors, and the wrapper errors, will be presented in the form of PlatformExceptions
. We want to emphasize that the property values of this object can be slightly different due to differences in the native SDKs.
Handling errors
You can catch PlatformExceptions
and then match them based on the error code. The Mobile SDK supplies constants for all error codes.
import 'package:onegini/errors/error_codes.dart';
try {
final biometricAuthenticator = await Onegini.instance.userClient
.getBiometricAuthenticator(profileId);
setState(() {
_biometricAuthenticator = biometricAuthenticator;
});
} on PlatformException catch (err) {
if (err.code != WrapperErrorCodes.biometricAuthenticationNotAvailable) {
showFlutterToast(err.message);
}
}
Details property
The details
property of the returned platform exception will contain an overview and sometimes additional data regarding the error. This data is represented using a LinkedHashMap
. The structure of this map is displayed below
{
message: "the message passed by the plugin; platformexception.message", //String
code: "the error code passed by the plugin: platformexception.code", // String
// Optional Response LinkedHashMap in case a resource call
response: {
url: "https://..", // String
statusCode: 404, // Integer
headers: {}, // LinkedHashMap
body: "json string of the requested body" // String
}
// Optional iOS native properties to give additional information for resource calls
iosCode: 10000 // Integer
iosMessage: "" // String
}