moto/moto/iot/exceptions.py

55 lines
1.6 KiB
Python
Raw Normal View History

from __future__ import unicode_literals
from moto.core.exceptions import JsonRESTError
class IoTClientError(JsonRESTError):
code = 400
class ResourceNotFoundException(IoTClientError):
def __init__(self):
self.code = 404
super(ResourceNotFoundException, self).__init__(
2019-10-31 08:44:26 -07:00
"ResourceNotFoundException", "The specified resource does not exist"
)
class InvalidRequestException(IoTClientError):
def __init__(self, msg=None):
self.code = 400
super(InvalidRequestException, self).__init__(
2019-10-31 08:44:26 -07:00
"InvalidRequestException", msg or "The request is not valid."
)
2019-04-29 13:26:33 +02:00
class InvalidStateTransitionException(IoTClientError):
def __init__(self, msg=None):
self.code = 409
super(InvalidStateTransitionException, self).__init__(
"InvalidStateTransitionException",
2019-12-23 09:01:53 +01:00
msg or "An attempt was made to change to an invalid state.",
2019-04-29 13:26:33 +02:00
)
class VersionConflictException(IoTClientError):
def __init__(self, name):
self.code = 409
super(VersionConflictException, self).__init__(
2019-10-31 08:44:26 -07:00
"VersionConflictException",
"The version for thing %s does not match the expected version." % name,
)
class CertificateStateException(IoTClientError):
def __init__(self, msg, cert_id):
self.code = 406
super(CertificateStateException, self).__init__(
2019-10-31 08:44:26 -07:00
"CertificateStateException", "%s Id: %s" % (msg, cert_id)
)
class DeleteConflictException(IoTClientError):
def __init__(self, msg):
self.code = 409
2019-10-31 08:44:26 -07:00
super(DeleteConflictException, self).__init__("DeleteConflictException", msg)