Sha256: c5200417731a69677978bdde027e303f1bc7483c14be4cd7ede6a7d9301f5a0a

Contents?: true

Size: 477 Bytes

Versions: 1

Compression:

Stored size: 477 Bytes

Contents

module Dry
  module Transaction
    class StepAdapters
      # @api private
      class Try
        def call(step, *args, input)
          unless step.options[:catch]
            raise ArgumentError, "+try+ steps require one or more exception classes provided via +catch:+"
          end

          Right(step.operation.call(*args, input))
        rescue *Array(step.options[:catch]) => e
          Left(e)
        end
      end

      register :try, Try.new
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-transaction-0.6.0 lib/dry/transaction/step_adapters/try.rb