Use specialised exception for "secret has no value" scenario

This commit is contained in:
Alexander Campbell 2019-10-18 12:06:12 +11:00
commit 30853a0b5c
2 changed files with 14 additions and 5 deletions

View file

@ -15,6 +15,7 @@ class ResourceNotFoundException(SecretsManagerClientError):
)
# Using specialised exception due to the use of a non-ASCII character
class SecretNotFoundException(SecretsManagerClientError):
def __init__(self):
self.code = 404
@ -24,6 +25,17 @@ class SecretNotFoundException(SecretsManagerClientError):
)
# Using specialised exception due to the use of a non-ASCII character
class SecretHasNoValueException(SecretsManagerClientError):
def __init__(self, version_stage):
self.code = 404
super(SecretHasNoValueException, self).__init__(
"ResourceNotFoundException",
message=u"Secrets Manager can\u2019t find the specified secret "
u"value for staging label: {}".format(version_stage)
)
class ClientError(SecretsManagerClientError):
def __init__(self, message):
super(ClientError, self).__init__(