5
5
// SPDX-License-Identifier: Apache-2.0
6
6
//
7
7
8
+ import Foundation
9
+
8
10
public enum AWSCognitoAuthError : Error {
9
11
10
12
/// User not found in the system.
@@ -13,7 +15,7 @@ public enum AWSCognitoAuthError: Error {
13
15
/// User not confirmed in the system.
14
16
case userNotConfirmed
15
17
16
- /// Username does not exists in the system.
18
+ /// Username already exists in the system.
17
19
case usernameExists
18
20
19
21
/// Alias already exists in the system.
@@ -40,7 +42,7 @@ public enum AWSCognitoAuthError: Error {
40
42
/// Amazon Cognito cannot find a multi-factor authentication (MFA) method.
41
43
case mfaMethodNotFound
42
44
43
- /// Software token TOTP multi-factor authentication (MFA) is not enabled for the user pool.
45
+ /// Software token ( TOTP) multi-factor authentication (MFA) is not enabled for the user pool.
44
46
case softwareTokenMFANotEnabled
45
47
46
48
/// Required to reset the password of the user.
@@ -55,7 +57,7 @@ public enum AWSCognitoAuthError: Error {
55
57
/// The user has made too many requests for a given operation.
56
58
case requestLimitExceeded
57
59
58
- /// Amazon Cognito service encounters an invalid AWS Lambda response or encounters an
60
+ /// Amazon Cognito service encountered an invalid AWS Lambda response or encountered an
59
61
/// unexpected exception with the AWS Lambda service.
60
62
case lambda
61
63
@@ -71,7 +73,7 @@ public enum AWSCognitoAuthError: Error {
71
73
/// Requested resource is not available with the current account setup.
72
74
case invalidAccountTypeException
73
75
74
- /// Request was not completed because of any network related issue
76
+ /// Request was not completed because of a network related issue
75
77
case network
76
78
77
79
/// SMS role related issue
@@ -107,6 +109,83 @@ public enum AWSCognitoAuthError: Error {
107
109
/// The relying party ID doesn't match
108
110
case webAuthnRelyingPartyMismatch
109
111
110
- /// The WebAuthm configuration is missing or incomplete
112
+ /// The WebAuthn configuration is missing or incomplete
111
113
case webAuthnConfigurationMissing
112
114
}
115
+
116
+ extension AWSCognitoAuthError : LocalizedError {
117
+ public var errorDescription : String ? {
118
+ var message : String = " "
119
+ switch self {
120
+ case . userNotFound:
121
+ message = " User not found in the system. "
122
+ case . userNotConfirmed:
123
+ message = " User not confirmed in the system. "
124
+ case . usernameExists:
125
+ message = " Username already exists in the system. "
126
+ case . aliasExists:
127
+ message = " Alias already exists in the system. "
128
+ case . codeDelivery:
129
+ message = " Error in delivering the confirmation code. "
130
+ case . codeMismatch:
131
+ message = " Confirmation code entered is not correct. "
132
+ case . codeExpired:
133
+ message = " Confirmation code has expired. "
134
+ case . invalidParameter:
135
+ message = " One or more parameters are incorrect. "
136
+ case . invalidPassword:
137
+ message = " Password given is invalid. "
138
+ case . limitExceeded:
139
+ message = " Limit exceeded for the requested AWS resource. "
140
+ case . mfaMethodNotFound:
141
+ message = " Amazon Cognito cannot find a multi-factor authentication (MFA) method. "
142
+ case . softwareTokenMFANotEnabled:
143
+ message = " Software token (TOTP) multi-factor authentication (MFA) is not enabled for the user pool. "
144
+ case . passwordResetRequired:
145
+ message = " Required to reset the password of the user. "
146
+ case . resourceNotFound:
147
+ message = " Amazon Cognito service cannot find the requested resource. "
148
+ case . failedAttemptsLimitExceeded:
149
+ message = " The user has made too many failed attempts for a given action. "
150
+ case . requestLimitExceeded:
151
+ message = " The user has made too many requests for a given operation. "
152
+ case . lambda:
153
+ message = " Amazon Cognito service encountered an invalid AWS Lambda response or encountered an unexpected exception with the AWS Lambda service. "
154
+ case . deviceNotTracked:
155
+ message = " Device is not tracked. "
156
+ case . errorLoadingUI:
157
+ message = " Error in loading the web UI. "
158
+ case . userCancelled:
159
+ message = " User cancelled the step. "
160
+ case . invalidAccountTypeException:
161
+ message = " Requested resource is not available with the current account setup. "
162
+ case . network:
163
+ message = " Request was not completed because of a network related issue. "
164
+ case . smsRole:
165
+ message = " SMS role related issue. "
166
+ case . emailRole:
167
+ message = " Email role related issue. "
168
+ case . externalServiceException:
169
+ message = " An external service like facebook/twitter threw an error. "
170
+ case . limitExceededException:
171
+ message = " Limit exceeded exception. Thrown when the total number of user pools has exceeded a preset limit. "
172
+ case . resourceConflictException:
173
+ message = " Thrown when a user tries to use a login which is already linked to another account. "
174
+ case . webAuthnChallengeNotFound:
175
+ message = " The WebAuthn credentials don't match an existing request. "
176
+ case . webAuthnClientMismatch:
177
+ message = " The client doesn't support WebAuhn authentication. "
178
+ case . webAuthnNotSupported:
179
+ message = " WebAuthn is not supported on this device. "
180
+ case . webAuthnNotEnabled:
181
+ message = " WebAuthn is not enabled. "
182
+ case . webAuthnOriginNotAllowed:
183
+ message = " The device origin is not registered as an allowed origin. "
184
+ case . webAuthnRelyingPartyMismatch:
185
+ message = " The relying party ID doesn't match. "
186
+ case . webAuthnConfigurationMissing:
187
+ message = " The WebAuthn configuration is missing or incomplete. "
188
+ }
189
+ return " \( String ( describing: Self . self) ) . \( self ) : \( message) "
190
+ }
191
+ }
0 commit comments