sendTaskFailure method

Future<void> sendTaskFailure({
  1. required String taskToken,
  2. String? cause,
  3. String? error,
})

Used by activity workers and task states using the callback pattern to report that the task identified by the taskToken failed.

May throw TaskDoesNotExist. May throw InvalidToken. 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 {
  ArgumentError.checkNotNull(taskToken, 'taskToken');
  _s.validateStringLength(
    'taskToken',
    taskToken,
    1,
    1024,
    isRequired: true,
  );
  _s.validateStringLength(
    'cause',
    cause,
    0,
    32768,
  );
  _s.validateStringLength(
    'error',
    error,
    0,
    256,
  );
  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,
    },
  );
}