invoke method

  1. @override
Future<RunOutput> invoke(
  1. RunInput input, {
  2. RunnableOptions? options,
})
override

Invokes the Runnable on the given input.

  • input - the input to invoke the Runnable on.
  • options - the options to use when invoking the Runnable.

Implementation

@override
Future<RunOutput> invoke(RunInput input, {RunnableOptions? options}) async {
  Object? firstError;
  for (final runnable in [mainRunnable, ...fallbacks]) {
    try {
      return await runnable.invoke(
        input,
        options: firstError == null
            ? options
            : runnable.getCompatibleOptions(options),
      );
    } catch (e) {
      firstError ??= e;
    }
  }
  throw Exception('All runnables failed. First error: $firstError');
}