Error handling
Every SDK operation reports failures as a SignicatOIDCException. Coroutine calls result in this exception; callback calls deliver it to onError.
Exception reference
The SignicatOIDCException includes a stable error code, in addition to any protocol details that the Signicat service returned.
You should decide how your app responds to errors based on errorCode rather than on the error message text. Error codes are part of the SDK contract, whereas messages are not.
Use error messages and OAuth descriptions to diagnose problems. Show end-users a message based on the error code.
For an overview of the exception properties, see the table below:
- Kotlin
- Java
try {
val session = client.login()
showLoggedInScreen(session)
} catch (error: SignicatOIDCException) {
when (error.errorCode) {
SignicatOIDCException.ErrorCode.authorizationCancelled -> showLoginScreen()
SignicatOIDCException.ErrorCode.noSupportedBrowser -> showInstallBrowserMessage()
SignicatOIDCException.ErrorCode.sessionExpired -> startLoginAgain()
else -> showGenericError()
}
}
@Override
public void onError(SignicatOIDCException error) {
switch (error.getErrorCode()) {
case authorizationCancelled:
showLoginScreen();
break;
case noSupportedBrowser:
showInstallBrowserMessage();
break;
case sessionExpired:
startLoginAgain();
break;
default:
showGenericError();
}
}
Error codes
For an overview of possible error codes, see the table below:
Log error detail
The toJson() method serialises the non-null error details into a compact JSON object. It always includes code and message, and adds the OAuth fields when the Signicat service provided them.
You can use this for diagnostics and support tickets.
catch (error: SignicatOIDCException) {
Log.e("MyApp", error.toJson())
}
{
"code": "tokenExchangeFailed",
"message": "OIDC token exchange failed.",
"oauthError": "invalid_grant",
"oauthErrorDescription": "The authorization code is invalid or has expired."
}
Support
If you need help or want to report an issue, contact us by creating a support ticket in the Signicat Dashboard.
When creating a support ticket, you should include the serialised error details from the toJson() method.