"""Explicit exceptions for SWF faults/errors."""importfunctoolsimportdataclassesimporttypingastift.TYPE_CHECKING:importbotocore.clientimportbotocore.exceptionsT=t.TypeVar("T")class_UnknownException(Exception):pass
[docs]classAccessDeniedException(SwfError):"""You do not have sufficient access to perform this action."""
[docs]classDefaultUndefinedFault(SwfError):"""The required parameters were not set for execution start. Some workflow execution parameters, such as the decision task-list, must be set to start the execution. However, these parameters might have been set as defaults when the workflow was registered. In this case, you can omit these arguments to ``start_execution`` and Amazon SWF uses the values defined in the workflow. Note: if these parameters aren't set and no default parameters were defined in the workflow, this error is displayed. """
[docs]classDomainAlreadyExistsFault(SwfError):"""The domain already exists. You may get this fault if you are registering a domain that is either already registered or deprecated, or if you undeprecate a domain that is currently registered. """
[docs]classDomainDeprecatedFault(SwfError):"""The specified domain has been deprecated."""
[docs]classInternalFailureError(SwfError):"""The request processing has failed because of an unknown error, exception or failure. """
[docs]classInvalidClientTokenIdError(SwfError):"""The X.509 certificate or AWS access key ID provided does not exist in our records. """
[docs]classInvalidParameterCombinationError(SwfError):"""Parameters that must not be used together were used together"""
[docs]classInvalidParameterValueError(SwfError):"""An invalid or out-of-range value was supplied for the input parameter."""
[docs]classLimitExceededFault(SwfError):"""A system-imposed limitation has been reached. To address this fault you should either clean up unused resources or increase the limit by contacting AWS. """
[docs]classMissingActionError(SwfError):"""The request is missing an action or a required parameter."""
[docs]classNotAuthorizedError(SwfError):"""You do not have permission to perform this action."""
[docs]classOperationNotPermittedFault(SwfError):"""The caller doesn't have sufficient permissions to invoke the action."""
[docs]classOptInRequiredError(SwfError):"""The AWS access key ID needs a subscription for the service."""
[docs]classRequestExpiredError(SwfError):"""The request reached the service more than 15 minutes after the date stamp on the request or more than 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp on the request is more than 15 minutes in the future. """
[docs]classServiceUnavailableError(SwfError):"""The request has failed due to a temporary failure of the server."""
[docs]classThrottlingException(SwfError):"""The request was denied due to request throttling."""
[docs]classTooManyTagsFault(SwfError):"""You've exceeded the number of tags allowed for a domain."""
[docs]classTypeAlreadyExistsFault(SwfError):"""The activity/workflow already exists in the specified domain. You may get this fault if you are registering an activity/workflow that is either already registered or deprecated, or if you undeprecate an activity/workflow that is currently registered. """
[docs]classTypeDeprecatedFault(SwfError):"""The specified activity or workflow type was already deprecated."""
[docs]classUnknownResourceFault(SwfError):"""The named resource cannot be found with in the scope of this operation (region or domain). This could happen if the named resource was never created or is no longer available for this operation. """
[docs]classValidationError(SwfError):"""The input fails to satisfy the constraints specified by an AWS service."""
[docs]classWorkflowExecutionAlreadyStartedFault(SwfError):"""An open execution with the same ID is already running in the specified domain. """
@dataclasses.dataclassclassExceptionRedirectMethodWrapper(t.Generic[T]):_f:t.Callable[...,T]def__post_init__(self):functools.update_wrapper(self,self._f)def__call__(self,*args,**kwargs)->T:importbotocore.exceptionstry:returnself._f(*args,**kwargs)exceptbotocore.exceptions.ClientErrorase:try:new_exception=SwfError.from_botocore_exception(e)except_UnknownException:passelse:raisenew_exceptionfrome.with_traceback(None)raisedef__getattr__(self,item:str):returngetattr(self._f,item)@dataclasses.dataclassclassExceptionRedirectClientWrapper:__client:"botocore.client.BaseClient"def__getattr__(self,item:str):value=getattr(self.__client,item)ifitem[:1]!="_"andhasattr(value,"__func__"):value=ExceptionRedirectMethodWrapper(value)setattr(self,item,value)# cachereturnvaluedefredirect_exceptions_in_swf_client(swf_client:"botocore.client.BaseClient",)->ExceptionRedirectClientWrapper:"""Redirect ``botocore`` client-error exceptions to custom exceptions. Args: swf_client: client to redirect exceptions from Returns: wrapped client """returnExceptionRedirectClientWrapper(swf_client)