-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update sdk error handling in AWSCognitoAuthPlugin (#3251)
- Loading branch information
Showing
49 changed files
with
561 additions
and
1,877 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...s/AWSCognitoAuthPlugin/Service/ErrorMapping/AWSCognitoIdentity+AuthErrorConvertible.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Foundation | ||
import Amplify | ||
import AWSCognitoIdentity | ||
import AWSClientRuntime | ||
|
||
// AWSCognitoIdentity | ||
extension AWSCognitoIdentity.ExternalServiceException: AuthErrorConvertible { | ||
var fallbackDescription: String { "External service threw error." } | ||
|
||
var authError: AuthError { | ||
.service( | ||
properties.message ?? fallbackDescription, | ||
AuthPluginErrorConstants.externalServiceException, | ||
AWSCognitoAuthError.externalServiceException | ||
) | ||
} | ||
} | ||
|
||
extension AWSCognitoIdentity.InternalErrorException: AuthErrorConvertible { | ||
var fallbackDescription: String { "Internal exception occurred" } | ||
|
||
var authError: AuthError { | ||
.unknown(properties.message ?? fallbackDescription) | ||
} | ||
} | ||
|
||
// AWSCognitoIdentity | ||
extension AWSCognitoIdentity.InvalidIdentityPoolConfigurationException: AuthErrorConvertible { | ||
var fallbackDescription: String { "Invalid IdentityPool Configuration error." } | ||
|
||
var authError: AuthError { | ||
.configuration( | ||
properties.message ?? fallbackDescription, | ||
AuthPluginErrorConstants.configurationError | ||
) | ||
} | ||
} | ||
|
||
extension AWSCognitoIdentity.InvalidParameterException: AuthErrorConvertible { | ||
var fallbackDescription: String { "Invalid parameter error" } | ||
|
||
var authError: AuthError { | ||
.service( | ||
properties.message ?? fallbackDescription, | ||
AuthPluginErrorConstants.invalidParameterError, | ||
AWSCognitoAuthError.invalidParameter | ||
) | ||
} | ||
} | ||
|
||
extension AWSCognitoIdentity.NotAuthorizedException: AuthErrorConvertible { | ||
var fallbackDescription: String { "Not authorized error." } | ||
|
||
var authError: AuthError { | ||
.notAuthorized( | ||
properties.message ?? fallbackDescription, | ||
AuthPluginErrorConstants.notAuthorizedError | ||
) | ||
} | ||
} | ||
|
||
extension AWSCognitoIdentity.ResourceConflictException: AuthErrorConvertible { | ||
var fallbackDescription: String { "Resource conflict error." } | ||
|
||
var authError: AuthError { | ||
.service( | ||
properties.message ?? fallbackDescription, | ||
AuthPluginErrorConstants.resourceConflictException, | ||
AWSCognitoAuthError.resourceConflictException | ||
) | ||
} | ||
} | ||
|
||
extension AWSCognitoIdentity.ResourceNotFoundException: AuthErrorConvertible { | ||
var fallbackDescription: String { "Resource not found error." } | ||
|
||
var authError: AuthError { | ||
.service( | ||
properties.message ?? fallbackDescription, | ||
AuthPluginErrorConstants.resourceNotFoundError, | ||
AWSCognitoAuthError.resourceNotFound | ||
) | ||
} | ||
} | ||
|
||
extension AWSCognitoIdentity.TooManyRequestsException: AuthErrorConvertible { | ||
var fallbackDescription: String { "Too many requests error." } | ||
|
||
var authError: AuthError { | ||
.service( | ||
properties.message ?? fallbackDescription, | ||
AuthPluginErrorConstants.tooManyRequestError, | ||
AWSCognitoAuthError.requestLimitExceeded | ||
) | ||
} | ||
} | ||
|
||
|
||
extension AWSCognitoIdentity.LimitExceededException: AuthErrorConvertible { | ||
var fallbackDescription: String { "Too many requests error." } | ||
|
||
var authError: AuthError { | ||
.service( | ||
properties.message ?? fallbackDescription, | ||
AuthPluginErrorConstants.limitExceededException, | ||
AWSCognitoAuthError.limitExceededException | ||
) | ||
} | ||
} |
Oops, something went wrong.