This topic guide describes how errors should be handled that are generated by the Onegini Android SDK. First we start with a general description on errors from which we slowly dive deeper into the world of error handling for the Android SDK.
Interaction with the Onegini SDK can result in errors. We have a pattern name for all error classes:
_TYPE_ is particular scenario
with different set of error which can occur. For example the
OneginiAuthenticationHandler in its
onError method returns the
which specifies that only the following errors can occur:
Apart from these error codes we will also provide you with a comprehensive error description which you can get by calling
getMessage() method on
OneginiError objects. The error description is in English and intended for you as a developer to understand what happened. They are not intended for
For a full list of all errors including a comprehensive description go to the errors reference guide
OneginiError also contains an instance of
OneginiErrorDetails that can be accesed by calling
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
For some errors, additional information can be received using this interface. For example, in case of failed authentication with custom authenticator, if the
error was returned by the custom authenticator script on the server side, then the
OneginiErrorDetails#getCustomInfo will return the
error details provided by the script (error code and data).
Every error has a code. This code uniquely identifies an error. For example the
OneginiAuthenticationError class contains the following errors:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
There are two ranges of error codes:
- from 9000 to 10.000: These codes are reserved for errors that you should show to your end-users. (E.g. they indicate that there was a connection problem with the Token Server or that the app version that is used by the end-user is outdated)
- 10.000 and higher: These are errors that usually will not happen or might indicate that there is a misconfiguration in the Token Server.
Example error handling code¶
It is not required to handle all errors that are returned by the SDK. You may decide based on the requirements of the application you are building which errors you find interesting and which you don't. The errors which are interesting for you can be easily selected; and for those errors you can implement specific error handling. Other errors can be combined into more generic error handling, such a showing to the end-user that something went wrong.
The example below shows how you can handle the errors that may occur during user registration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
We have compiled a matrix of SDK methods and errors. This provides an easy overview of which errors may occur in every SDK method. Unfortunately it is too big to show it on the current page. Hence you must click on the previous link to view this matrix.