Sha256: fafb184b7535c6d3c403b68392dd38ef18b5609ad2f4da840f7512780f0c8a9e

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 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 start(input)
          super
          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, input) : error,
            "Cause" => @cause_path ? @cause_path.value(context, input) : cause
          }.compact
          context.state["Error"] = context.output["Error"]
          context.state["Cause"] = context.output["Cause"]
        end

        def running?
          false
        end

        def end?
          true
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
floe-0.9.0 lib/floe/workflow/states/fail.rb
floe-0.7.1 lib/floe/workflow/states/fail.rb
floe-0.8.0 lib/floe/workflow/states/fail.rb
floe-0.7.0 lib/floe/workflow/states/fail.rb
floe-0.6.1 lib/floe/workflow/states/fail.rb
floe-0.6.0 lib/floe/workflow/states/fail.rb
floe-0.5.0 lib/floe/workflow/states/fail.rb
floe-0.4.1 lib/floe/workflow/states/fail.rb