Sha256: c1160f8fb51895bbfba674ccafa3a52667ec289bfb4eaf907bce8b59cf10008a

Contents?: true

Size: 691 Bytes

Versions: 3

Compression:

Stored size: 691 Bytes

Contents

class Trailblazer::Operation
  module Rescue
    Noop = ->(*) {}

    def self.import!(_operation, import, *exceptions, handler: Noop, &block)
      exceptions = [StandardError] unless exceptions.any?
      handler    = Option.(handler)

      rescue_block = ->(options, operation, *, &nested_pipe) {
        begin
          res = nested_pipe.call
          res.first == ::Pipetree::Flow::Right # FIXME.
        rescue *exceptions => exception
          handler.call(operation, exception, options)
          false
        end
      }

      Wrap.import! _operation, import, rescue_block, name: "Rescue:#{block.source_location.last}", &block
    end
  end

  DSL.macro!(:Rescue, Rescue)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trailblazer-2.0.0 lib/trailblazer/operation/rescue.rb
trailblazer-2.0.0.rc1 lib/trailblazer/operation/rescue.rb
trailblazer-2.0.0.beta3 lib/trailblazer/operation/rescue.rb