processStepResult method

Future<void> processStepResult(
  1. S step,
  2. StepResult result
)

Implementation

Future<void> processStepResult(S step, StepResult result) async {
  __.in_('processStepResult');
  try {
    checkInitialized('FlowManager');

    if (_activeFlow == null) {
      throw Exception('No active flow to process step result');
    }

    // Process the result in the active flow
    await _activeFlow!.processStepResult(step, result);

    // If this was the last step and result is done, the flow should be ended
    if (step == _activeFlow!.getLastStep() && result == StepResult.stepDone) {
      // The flow's complete method will call onEnd which will call endFlow
      await _activeFlow!.complete();
    }
  } catch (e, stackTrace) {
    final wrapped = hujFlowException(
      message: 'Failed to process step result: $step',
      hujType: hujErrorType.flow,
      originalError: e,
    );
    __.severe(wrapped.message, wrapped, stackTrace);
    throw wrapped;
  } finally {
    __.out_('processStepResult');
  }
}