Sha256: 7aca1626af5559300907a5f16f6af0d481458f0effa3130daa57f122d536f78e
Contents?: true
Size: 595 Bytes
Versions: 2
Compression:
Stored size: 595 Bytes
Contents
module Dry module Transaction class StepAdapters # @api private class Try include Dry::Monads::Either::Mixin 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 e = step.options[:raise].new(e.message) if step.options[:raise] Left(e) end end register :try, Try.new end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-transaction-0.8.0 | lib/dry/transaction/step_adapters/try.rb |
dry-transaction-0.7.0 | lib/dry/transaction/step_adapters/try.rb |