Sha256: 4e35fa212fb6d273b33ba918cf4ef0b4f795042a0781e76cbae58d6d92a154c3

Contents?: true

Size: 547 Bytes

Versions: 3

Compression:

Stored size: 547 Bytes

Contents

module NxtPipeline
  class ErrorCallback
    def initialize(errors, halt_on_error, &callback)
      @errors = errors.any? ? errors : [StandardError]
      @halt_on_error = halt_on_error
      @callback = callback
    end

    attr_accessor :errors, :callback

    def halt_on_error?
      @halt_on_error
    end

    def continue_after_error?
      !halt_on_error?
    end

    def applies_to_error?(error)
      (error.class.ancestors & errors).any?
    end

    def call(step, arg, error)
      callback.call(step, arg, error)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nxt_pipeline-1.0.0 lib/nxt_pipeline/error_callback.rb
nxt_pipeline-0.4.3 lib/nxt_pipeline/error_callback.rb
nxt_pipeline-0.4.2 lib/nxt_pipeline/error_callback.rb