sendTaskFailure method
Used by activity workers, Task states using the callback
pattern, and optionally Task states using the job
run pattern to report that the task identified by the
taskToken failed.
For an execution with encryption enabled, Step Functions will encrypt the error and cause fields using the KMS key for the execution role.
A caller can mark a task as fail without using any KMS permissions in the
execution role if the caller provides a null value for both
error and cause fields because no data needs to
be encrypted.
May throw InvalidToken.
May throw KmsAccessDeniedException.
May throw KmsInvalidStateException.
May throw KmsThrottlingException.
May throw TaskDoesNotExist.
May throw TaskTimedOut.
Parameter taskToken :
The token that represents this task. Task tokens are generated by Step
Functions when tasks are assigned to a worker, or in the context
object when a workflow enters a task state. See
GetActivityTaskOutput$taskToken.
Parameter cause :
A more detailed explanation of the cause of the failure.
Parameter error :
The error code of the failure.
Implementation
Future<void> sendTaskFailure({
required String taskToken,
String? cause,
String? error,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'AWSStepFunctions.SendTaskFailure'
};
await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'taskToken': taskToken,
if (cause != null) 'cause': cause,
if (error != null) 'error': error,
},
);
}