Error handling
Silhouette throws a huge range of exceptions from its core. But it's easy to handle these in your application, because they are grouped and therefore you can either react to single errors or to a group of errors to provide your users an appropriated result.
Exception types
Below you can find the exception hierarchy provided by Silhouette.
SilhouetteException
This is the base exception. All other exceptions are derived from this exception. So to react to all Silhouette related errors you must only catch this exception.
NotAuthenticatedException
This exception type indicates that a user is not authenticated to access a secured endpoint. This exception type will be handled by the endpoint error handlers.
NotAuthorizedException
This exception type indicates that the authenticated user is not authorized to access a secured endpoint. This exception type will be handled by the endpoint error handlers.
CryptoException
This exception type indicates that an error occurred in a cryptography related functionality.
AuthenticatorException
This is the base exception for all authenticator related errors. Silhouette provides also some derived exceptions types which allow you to react of single authenticator related errors. Below you can see the list of them:
Type | Description |
---|---|
AuthenticatorCreationException | An exception thrown when there is an error during authenticator creation |
AuthenticatorRetrievalException | An exception thrown when there is an error during authenticator retrieval |
AuthenticatorInitializationException | An exception thrown when there is an error during authenticator initialization |
AuthenticatorUpdateException | An exception thrown when there is an error during authenticator update |
AuthenticatorRenewalException | An exception thrown when there is an error during authenticator renewal |
AuthenticatorDiscardingException | An exception thrown when there is an error during authenticator discarding |
ProviderException
This is the base exception for all provider related errors. Silhouette provides also some derived exceptions types which allow you to react of single provider related errors. Below you can see the list of them:
Type | Description |
---|---|
AccessDeniedException | Signals that a social provider denies access during authentication process |
IdentityNotFoundException | Signals that an identity could not found in a credential based provider |
InvalidPasswordException | Indicates that an invalid password was entered in a credential based provider |
OAuth1TokenSecretException | Indicates that an error occurred during OAuth1 token secret retrieval |
OAuth2StateException | Indicates that an error occurred during OAuth2 state retrieval |
ProfileRetrievalException | Indicates that an error occurred during profile retrieval in a social provider |
UnexpectedResponseException | Signals that an unexpected response was received from a social provider |
ConfigurationException
This exception type indicates a misconfiguration of a Silhouette component.
Note
Due to the asynchronous nature of Silhouette, all exceptions will be thrown in Futures. This means that exceptions may not be caught in a
try catch
block because Futures may be executed in separate Threads. To solve this problem, Futures have their own error handling mechanism. They can be recovered from an error state into desirable state with the help of therecover
andrecoverWith
methods. Both methods accept a partial function which transforms theException
into any other type. For more information please visit theFuture
trait's documentation.
Updated less than a minute ago