Cleanup SWF to use HTTP exceptions so that the standalone server will work. Closes #495.
This commit is contained in:
parent
075d008509
commit
a53a97d136
12 changed files with 136 additions and 142 deletions
|
|
@ -1,14 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from boto.exception import JSONResponseError
|
||||
from moto.core.exceptions import JsonRESTError
|
||||
|
||||
|
||||
class SWFClientError(JSONResponseError):
|
||||
def __init__(self, message, __type):
|
||||
super(SWFClientError, self).__init__(
|
||||
400, "Bad Request",
|
||||
body={"message": message, "__type": __type}
|
||||
)
|
||||
class SWFClientError(JsonRESTError):
|
||||
code = 400
|
||||
|
||||
|
||||
class SWFUnknownResourceFault(SWFClientError):
|
||||
|
|
@ -18,54 +14,59 @@ class SWFUnknownResourceFault(SWFClientError):
|
|||
else:
|
||||
message = "Unknown {0}".format(resource_type)
|
||||
super(SWFUnknownResourceFault, self).__init__(
|
||||
"com.amazonaws.swf.base.model#UnknownResourceFault",
|
||||
message,
|
||||
"com.amazonaws.swf.base.model#UnknownResourceFault")
|
||||
)
|
||||
|
||||
|
||||
class SWFDomainAlreadyExistsFault(SWFClientError):
|
||||
def __init__(self, domain_name):
|
||||
super(SWFDomainAlreadyExistsFault, self).__init__(
|
||||
"com.amazonaws.swf.base.model#DomainAlreadyExistsFault",
|
||||
domain_name,
|
||||
"com.amazonaws.swf.base.model#DomainAlreadyExistsFault")
|
||||
)
|
||||
|
||||
|
||||
class SWFDomainDeprecatedFault(SWFClientError):
|
||||
def __init__(self, domain_name):
|
||||
super(SWFDomainDeprecatedFault, self).__init__(
|
||||
"com.amazonaws.swf.base.model#DomainDeprecatedFault",
|
||||
domain_name,
|
||||
"com.amazonaws.swf.base.model#DomainDeprecatedFault")
|
||||
)
|
||||
|
||||
|
||||
class SWFSerializationException(JSONResponseError):
|
||||
class SWFSerializationException(SWFClientError):
|
||||
def __init__(self, value):
|
||||
message = "class java.lang.Foo can not be converted to an String "
|
||||
message += " (not a real SWF exception ; happened on: {0})".format(value)
|
||||
__type = "com.amazonaws.swf.base.model#SerializationException"
|
||||
super(SWFSerializationException, self).__init__(
|
||||
400, "Bad Request",
|
||||
body={"Message": message, "__type": __type}
|
||||
__type,
|
||||
message,
|
||||
)
|
||||
|
||||
|
||||
class SWFTypeAlreadyExistsFault(SWFClientError):
|
||||
def __init__(self, _type):
|
||||
super(SWFTypeAlreadyExistsFault, self).__init__(
|
||||
"com.amazonaws.swf.base.model#TypeAlreadyExistsFault",
|
||||
"{0}=[name={1}, version={2}]".format(_type.__class__.__name__, _type.name, _type.version),
|
||||
"com.amazonaws.swf.base.model#TypeAlreadyExistsFault")
|
||||
)
|
||||
|
||||
|
||||
class SWFTypeDeprecatedFault(SWFClientError):
|
||||
def __init__(self, _type):
|
||||
super(SWFTypeDeprecatedFault, self).__init__(
|
||||
"com.amazonaws.swf.base.model#TypeDeprecatedFault",
|
||||
"{0}=[name={1}, version={2}]".format(_type.__class__.__name__, _type.name, _type.version),
|
||||
"com.amazonaws.swf.base.model#TypeDeprecatedFault")
|
||||
)
|
||||
|
||||
|
||||
class SWFWorkflowExecutionAlreadyStartedFault(JSONResponseError):
|
||||
class SWFWorkflowExecutionAlreadyStartedFault(SWFClientError):
|
||||
def __init__(self):
|
||||
super(SWFWorkflowExecutionAlreadyStartedFault, self).__init__(
|
||||
400, "Bad Request",
|
||||
body={"__type": "com.amazonaws.swf.base.model#WorkflowExecutionAlreadyStartedFault"}
|
||||
"com.amazonaws.swf.base.model#WorkflowExecutionAlreadyStartedFault",
|
||||
"Already Started",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -77,15 +78,16 @@ class SWFDefaultUndefinedFault(SWFClientError):
|
|||
for word in words:
|
||||
key_camel_case += word.capitalize()
|
||||
super(SWFDefaultUndefinedFault, self).__init__(
|
||||
key_camel_case, "com.amazonaws.swf.base.model#DefaultUndefinedFault"
|
||||
"com.amazonaws.swf.base.model#DefaultUndefinedFault",
|
||||
key_camel_case,
|
||||
)
|
||||
|
||||
|
||||
class SWFValidationException(SWFClientError):
|
||||
def __init__(self, message):
|
||||
super(SWFValidationException, self).__init__(
|
||||
"com.amazon.coral.validate#ValidationException",
|
||||
message,
|
||||
"com.amazon.coral.validate#ValidationException"
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -116,8 +118,8 @@ class SWFDecisionValidationException(SWFClientError):
|
|||
else:
|
||||
prefix = "{0} validation errors detected: "
|
||||
super(SWFDecisionValidationException, self).__init__(
|
||||
"com.amazon.coral.validate#ValidationException",
|
||||
prefix.format(count) + "; ".join(messages),
|
||||
"com.amazon.coral.validate#ValidationException"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue