Amazon Cognito Identity Providerでは異なるエラー内容でも同じエラーコードが発行されるものがある。
エラー内容ごとにエラーハンドリングを行う必要がある場合は、エラーメッセージを確認することで区別が可能である。
ここでは一部の実際に確認したものを掲載する。
AliasExistsException
{'Message': 'Already found an entry for the provided username.', 'Code': 'AliasExistsException'}
CodeMismatchException
{'Message': 'Invalid session provided', 'Code': 'CodeMismatchException'}
ExpiredCodeException
{'Message': 'Invalid code provided, please request a code again.', 'Code': 'ExpiredCodeException'}
GroupExistsException
{'Message': 'A group with the name already exists.', 'Code': 'GroupExistsException'}
InvalidParameterException
{'Message': 'Attributes did not conform to the schema: {attributes}: Attribute does not exist in the schema.\n', 'Code': 'InvalidParameterException'}
{'Message': 'Invalid email address format.', 'Code': 'InvalidParameterException'}
{'Message': "1 validation error detected: Value 'string' at 'userPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\w-]+_[0-9a-zA-Z]+", 'Code': 'InvalidParameterException'}
InvalidPasswordException
{'Message': 'Password did not conform with password policy: Password not long enough', 'Code': 'InvalidPasswordException'}
{'Message': 'Password did not conform with password policy: Password must have uppercase characters', 'Code': 'InvalidPasswordException'}
{'Message': 'Password did not conform with password policy: Password must have numeric characters', 'Code': 'InvalidPasswordException'}
{'Message': 'Password did not conform with password policy: Password must have lowercase characters', 'Code': 'InvalidPasswordException'}
LimitExceededException
{'Attempt limit exceeded, please try after some time.', 'Code': LimitExceededException'}
NotAuthorizedException
{'Message': 'Incorrect username or password.', 'Code': 'NotAuthorizedException'}
{'Message': 'Invalid Access Token', 'Code': 'NotAuthorizedException'}
{'Message': 'Invalid Refresh Token', 'Code': 'NotAuthorizedException'}
ResourceNotFoundException
{'Message': 'Group not found.', 'Code': 'ResourceNotFoundException'}
UsernameExistsException
{'Message': 'User account already exists', 'Code': 'UsernameExistsException'}
{'Message': 'An account with the email already exists.', 'Code': 'UsernameExistsException'}
UserNotFoundException
{'Message': 'User does not exist.', 'Code': 'UserNotFoundException'}