Sha256: a30f7380849d63a4d7c7edceec4099aea329f07198fce72321aaa4b56a77e1c1

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Floe
  class Workflow
    module States
      class Fail < Floe::Workflow::State
        attr_reader :cause, :error

        def initialize(workflow, name, payload)
          super

          @cause      = payload["Cause"]
          @error      = payload["Error"]
          @cause_path = Path.new(payload["CausePath"]) if payload["CausePath"]
          @error_path = Path.new(payload["ErrorPath"]) if payload["ErrorPath"]
        end

        def finish
          context.next_state = nil
          # TODO: support intrinsic functions here
          # see https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-fail-state.html
          #     https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html#asl-intrsc-func-generic
          context.output     = {
            "Error" => @error_path ? @error_path.value(context, context.input) : error,
            "Cause" => @cause_path ? @cause_path.value(context, context.input) : cause
          }.compact
          super
        end

        def running?
          false
        end

        def end?
          true
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
floe-0.11.0 lib/floe/workflow/states/fail.rb
floe-0.10.0 lib/floe/workflow/states/fail.rb