Sha256: d0bca7f33acca126e7a68d045046646e17c03fe3d083e47fe9ff4583b88115fa

Contents?: true

Size: 687 Bytes

Versions: 2

Compression:

Stored size: 687 Bytes

Contents

class Trailblazer::Operation
  module Rescue
    def self.import!(_operation, import, *exceptions, handler:->(*){}, &block)
      exceptions = [StandardError] unless exceptions.any?
      handler    = Pipetree::DSL::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

2 entries across 2 versions & 1 rubygems

Version Path
trailblazer-2.0.0.beta2 lib/trailblazer/operation/rescue.rb
trailblazer-2.0.0.beta1 lib/trailblazer/operation/rescue.rb