markFailed method

  1. @override
Future<void> markFailed(
  1. String runId,
  2. Object error,
  3. StackTrace stack, {
  4. bool terminal = false,
})
override

Marks the run as failed and records error and stack.

Implementation

@override
Future<void> markFailed(
  String runId,
  Object error,
  StackTrace stack, {
  bool terminal = false,
}) async {
  final state = _runs[runId];
  if (state == null || state.isTerminal) return;
  if (terminal) {
    _removeWatcherForRun(runId);
    for (final entry in _due.values) {
      entry.remove(runId);
    }
  }
  _runs[runId] = state.copyWith(
    status: terminal ? WorkflowStatus.failed : WorkflowStatus.running,
    lastError: {'error': error.toString(), 'stack': stack.toString()},
    resumeAt: terminal ? null : state.resumeAt,
    waitTopic: terminal ? null : state.waitTopic,
    suspensionData: terminal
        ? const <String, Object?>{}
        : state.suspensionData,
    ownerId: terminal ? null : state.ownerId,
    leaseExpiresAt: terminal ? null : state.leaseExpiresAt,
    updatedAt: _clock.now(),
  );
}