moto/moto/sqs/exceptions.py

151 lines
3.9 KiB
Python
Raw Normal View History

from __future__ import unicode_literals
from moto.core.exceptions import RESTError
2014-11-15 14:35:52 +00:00
2014-06-20 21:31:19 +00:00
class MessageNotInflight(Exception):
description = "The message referred to is not in flight."
status_code = 400
class ReceiptHandleIsInvalid(RESTError):
code = 400
def __init__(self):
super(ReceiptHandleIsInvalid, self).__init__(
2019-10-31 15:44:26 +00:00
"ReceiptHandleIsInvalid", "The input receipt handle is invalid."
)
class MessageAttributesInvalid(RESTError):
code = 400
2014-11-15 14:53:45 +00:00
def __init__(self, description):
super(MessageAttributesInvalid, self).__init__(
"MessageAttributesInvalid", description
)
2017-10-10 19:51:48 +00:00
2019-10-18 07:04:29 +00:00
class QueueDoesNotExist(RESTError):
2021-08-26 15:23:17 +00:00
code = 400
2019-10-18 07:04:29 +00:00
def __init__(self):
2021-08-26 15:23:17 +00:00
super().__init__(
"AWS.SimpleQueueService.NonExistentQueue",
2019-10-31 15:44:26 +00:00
"The specified queue does not exist for this wsdl version.",
2021-08-26 15:23:17 +00:00
template="wrapped_single_error",
2019-10-31 15:44:26 +00:00
)
class QueueAlreadyExists(RESTError):
code = 400
def __init__(self, message):
2019-10-31 15:44:26 +00:00
super(QueueAlreadyExists, self).__init__("QueueAlreadyExists", message)
2019-10-26 20:08:45 +00:00
class EmptyBatchRequest(RESTError):
code = 400
def __init__(self):
super(EmptyBatchRequest, self).__init__(
2019-10-31 15:44:26 +00:00
"EmptyBatchRequest",
"There should be at least one SendMessageBatchRequestEntry in the request.",
2019-10-26 20:08:45 +00:00
)
class InvalidBatchEntryId(RESTError):
code = 400
def __init__(self):
super(InvalidBatchEntryId, self).__init__(
2019-10-31 15:44:26 +00:00
"InvalidBatchEntryId",
"A batch entry id can only contain alphanumeric characters, "
"hyphens and underscores. It can be at most 80 letters long.",
2019-10-26 20:08:45 +00:00
)
class BatchRequestTooLong(RESTError):
code = 400
def __init__(self, length):
super(BatchRequestTooLong, self).__init__(
2019-10-31 15:44:26 +00:00
"BatchRequestTooLong",
"Batch requests cannot be longer than 262144 bytes. "
"You have sent {} bytes.".format(length),
2019-10-26 20:08:45 +00:00
)
class BatchEntryIdsNotDistinct(RESTError):
code = 400
def __init__(self, entry_id):
super(BatchEntryIdsNotDistinct, self).__init__(
2019-10-31 15:44:26 +00:00
"BatchEntryIdsNotDistinct", "Id {} repeated.".format(entry_id)
2019-10-26 20:08:45 +00:00
)
class TooManyEntriesInBatchRequest(RESTError):
code = 400
def __init__(self, number):
super(TooManyEntriesInBatchRequest, self).__init__(
2019-10-31 15:44:26 +00:00
"TooManyEntriesInBatchRequest",
"Maximum number of entries per request are 10. "
"You have sent {}.".format(number),
2019-10-26 20:08:45 +00:00
)
class InvalidAttributeName(RESTError):
code = 400
def __init__(self, attribute_name):
super(InvalidAttributeName, self).__init__(
2019-10-31 15:44:26 +00:00
"InvalidAttributeName", "Unknown Attribute {}.".format(attribute_name)
)
class InvalidAttributeValue(RESTError):
code = 400
def __init__(self, attribute_name):
super(InvalidAttributeValue, self).__init__(
"InvalidAttributeValue",
"Invalid value for the parameter {}.".format(attribute_name),
)
class InvalidParameterValue(RESTError):
code = 400
def __init__(self, message):
super(InvalidParameterValue, self).__init__("InvalidParameterValue", message)
class MissingParameter(RESTError):
code = 400
def __init__(self, parameter):
super(MissingParameter, self).__init__(
"MissingParameter",
"The request must contain the parameter {}.".format(parameter),
)
class OverLimit(RESTError):
code = 403
def __init__(self, count):
super(OverLimit, self).__init__(
"OverLimit", "{} Actions were found, maximum allowed is 7.".format(count)
)
class InvalidAddress(RESTError):
code = 400
def __init__(self, address):
super(InvalidAddress, self).__init__(
"InvalidAddress",
"The address {} is not valid for this endpoint.".format(address),
)