1"""Exceptions raised by the sdb service.""" 2from moto.core.exceptions import RESTError 3 4 5SDB_ERROR = """<?xml version="1.0"?> 6<Response> 7 <Errors> 8 <Error> 9 <Code>{{ error_type }}</Code> 10 <Message>{{ message }}</Message> 11 <BoxUsage>0.0055590278</BoxUsage> 12 </Error> 13 </Errors> 14 <RequestID>ba3a8c86-dc37-0a45-ef44-c6cf7876a62f</RequestID> 15</Response>""" 16 17 18class InvalidParameterError(RESTError): 19 code = 400 20 21 def __init__(self, **kwargs): 22 kwargs.setdefault("template", "sdb_error") 23 self.templates["sdb_error"] = SDB_ERROR 24 kwargs["error_type"] = "InvalidParameterValue" 25 super().__init__(**kwargs) 26 27 28class InvalidDomainName(InvalidParameterError): 29 code = 400 30 31 def __init__(self, domain_name): 32 super().__init__( 33 message=f"Value ({domain_name}) for parameter DomainName is invalid. " 34 ) 35 36 37class UnknownDomainName(RESTError): 38 code = 400 39 40 def __init__(self, **kwargs): 41 kwargs.setdefault("template", "sdb_error") 42 self.templates["sdb_error"] = SDB_ERROR 43 kwargs["error_type"] = "NoSuchDomain" 44 kwargs["message"] = "The specified domain does not exist." 45 super().__init__(**kwargs) 46