Skip to main content

smart_id_rust_client/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, SmartIdClientError>;
4
5#[derive(Error, Debug)]
6#[non_exhaustive]
7#[allow(dead_code)]
8pub enum SmartIdClientError {
9    /// Config Exception
10    #[error("Configuration missing: {0}")]
11    ConfigMissingException(&'static str),
12
13    /// Serialization Error
14    #[error("Serialization error: {0}")]
15    SerializationError(String),
16
17    ///RelyingPartyAccountConfigurationException
18    #[error("Relying Party account configuration exception: {0}")]
19    RelyingPartyAccountConfigurationException(&'static str),
20
21    ///SmartIdClientException
22    #[error("Smart ID client exception: {0}")]
23    SmartIdClientException(&'static str),
24
25    ///SmartIDAPIException
26    #[error("Smart ID API Exception: {0}")]
27    SmartIDAPIException(String),
28
29    /// Session timed out without getting any response from user
30    #[error("Session timed out without getting any response from user")]
31    SessionTimeoutException,
32
33    /// There is no running session
34    #[error("There is no running session")]
35    NoSessionException,
36
37    /// Failed to get the running session
38    #[error("Failed to get the running session")]
39    GetSessionException,
40
41    /// Failed to set the running session
42    #[error("Failed to set the running session")]
43    SetSessionException,
44
45    /// Failed to get user identity
46    #[error("Failed to get user identity")]
47    GetUserIdentityException,
48
49    /// Failed to set user identity
50    #[error("Failed to set user identity")]
51    SetUserIdentityException,
52
53    /// Get signing certificate failed
54    #[error("Get signing certificate failed: {0}")]
55    GetSigningCertificateException(String),
56
57    /// Authentication session completed without result
58    #[error("Authentication session completed without result")]
59    AuthenticationSessionCompletedWithoutResult,
60
61    /// Session did not complete within timeout
62    #[error("Session did not complete within timeout")]
63    StatusRequestLongPollingTimeoutException,
64
65    /// Session does not exist or has expired
66    #[error("Session does not exist or has expired")]
67    SessionDoesNotExistOrHasExpired,
68
69    /// Api client is too old and is not supported anymore
70    #[error("Api client is too old and is not supported anymore")]
71    ApiClientIsTooOldException,
72
73    /// System is under maintenance and is not available
74    #[error("System is under maintenance and is not available")]
75    SystemIsUnderMaintenanceException,
76
77    /// Session response missing certificate
78    #[error("Session response missing certificate")]
79    SessionResponseMissingCertificate,
80
81    /// Session response missing signature
82    #[error("Session response missing signature")]
83    SessionResponseMissingSignature,
84
85    /// Session response missing interaction type
86    #[error("Session response missing interaction type")]
87    SessionResponseMissingInteractionType,
88
89    /// Session response signature verification failed
90    #[error("Session response signature verification failed: {0}")]
91    InvalidResponseSignature(String),
92
93    /// User has multiple accounts and pressed Cancel on device choice screen on any device
94    #[error("User has multiple accounts and pressed Cancel on device choice screen on any device")]
95    UserRefusedCertChoiceException,
96
97    /// User cancelled on confirmationMessage screen
98    #[error("User cancelled on confirmationMessage screen")]
99    UserRefusedConfirmationMessageException,
100
101    /// User cancelled on confirmationMessageAndVerificationCodeChoice screen
102    #[error("User cancelled on confirmationMessageAndVerificationCodeChoice screen")]
103    UserRefusedConfirmationMessageWithVerificationChoiceException,
104
105    /// User pressed Cancel on PIN screen
106    #[error("User pressed Cancel on PIN screen")]
107    UserRefusedDisplayTextAndPinException,
108
109    /// User cancelled verificationCodeChoice screen
110    #[error("User cancelled verificationCodeChoice screen")]
111    UserRefusedVerificationChoiceException,
112
113    /// User selected wrong verification code
114    #[error("User selected wrong verification code")]
115    UserSelectedWrongVerificationCodeException,
116
117    /// DOCUMENT_UNUSABLE. User must either check his/her Smart-ID mobile application or turn to customer support for getting the exact reason.
118    #[error("DOCUMENT_UNUSABLE. User must either check his/her Smart-ID mobile application or turn to customer support for getting the exact reason")]
119    DocumentUnusableException,
120
121    /// No suitable account of requested type found, but user has some other accounts
122    #[error("No suitable account of requested type found, but user has some other accounts")]
123    NoSuitableAccountOfRequestedTypeFoundException,
124
125    /// Person should view Smart-ID app or Smart-ID self-service portal now
126    #[error("Person should view Smart-ID app or Smart-ID self-service portal now")]
127    PersonShouldViewSmartIdPortalException,
128
129    /// User app version does not support any of the allowedInteractionsOrder interactions
130    #[error("User app version does not support any of the allowedInteractionsOrder interactions")]
131    RequiredInteractionNotSupportedByAppException,
132
133    /// Interaction parameters are invalid
134    #[error("Interaction parameters are invalid: {0}")]
135    InvalidInteractionParametersException(&'static str),
136
137    /// Failed to generate device link
138    #[error("Failed to generate device link: {0}")]
139    GenerateDeviceLinkException(&'static str),
140
141    /// Invalid signature protocol
142    #[error("Invalid signature protocol: {0}")]
143    InvalidSignatureProtocal(&'static str),
144
145    /// Failed to validate session response certificate
146    #[error("Failed to validate session response certificate: {0}")]
147    FailedToValidateSessionResponseCertificate(String),
148
149    /// Digest is not in valid format
150    #[error("Digest is not in valid format: {0}")]
151    InvalidDigestException(String),
152
153    /// User should view Smart-ID app or portal
154    #[error("User should view Smart-ID app or portal")]
155    UserShouldViewSmartIDAppOrPortalException,
156
157    /// Not found exception from Smart ID API
158    #[error("Not found exception from Smart ID API")]
159    NotFoundException,
160
161    /// Bad request exception from Smart ID API
162    #[error("Bad request exception from Smart ID API")]
163    BadRequestException,
164
165    /// Smart ID client is outdated
166    #[error("Smart ID client is outdated")]
167    ClientOutdatedException,
168
169    /// Invalid semantic identifier
170    #[error("Invalid semantic identifier: {0}")]
171    InvalidSemanticIdentifierException(String),
172
173    // Protocol Failure Exception
174    #[error("Protocol failure exception")]
175    ProtocolFailureException,
176
177    // Server Error Exception
178    #[error("Server error exception")]
179    ServerErrorException,
180}