File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
AmplifyPlugins/Auth/AWSCognitoAuthPlugin/Dependency Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -260,9 +260,25 @@ extension AuthenticationProviderAdapter {
260260 break
261261 }
262262 }
263+ if self . isErrorCausedByBadRequest ( error) {
264+ let errorDescription = error. _userInfo ? [ " error " ] ?
265+ . description. trimmingCharacters ( in: . whitespaces) ?? " unknown error "
266+ return AuthError . service ( errorDescription,
267+ AuthPluginErrorConstants . hostedUIBadRequestError,
268+ error)
269+ }
263270 let authError = AuthErrorHelper . toAuthError ( error)
264271 return authError
265272 }
273+
274+ private func isErrorCausedByBadRequest( _ error: Error ? ) -> Bool {
275+ if let cognitoAuthError = error as NSError ? ,
276+ cognitoAuthError. domain == AWSCognitoAuthErrorDomain,
277+ cognitoAuthError. code == AWSCognitoAuthClientErrorType . errorBadRequest. rawValue {
278+ return true
279+ }
280+ return false
281+ }
266282
267283 private class ModalPresentingNavigationController : UINavigationController {
268284
You can’t perform that action at this time.
0 commit comments