fail method

void fail(
  1. Object? error, [
  2. StackTrace? stack
])

Marks the open step Failed with error (and stack when caught separately). A child step that already carries the message keeps it, so fail text stays XOR along the tree.

Implementation

void fail(Object? error, [StackTrace? stack]) {
  final node = _node;
  if (node == null) return;
  node.result = 'Failed';
  for (final child in node.children) {
    if (child.errorMessage.isNotEmpty) return;
  }
  node.errorMessage = appendText(
    node.errorMessage,
    formatFailureText(error, stack),
  );
}