Class: Dry::Transaction::StepAdapters::Try Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/transaction/step_adapters/try.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#call(operation, options, args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dry/transaction/step_adapters/try.rb', line 12

def call(operation, options, args)
  unless options[:catch]
    raise MissingCatchListError, options[:step_name]
  end

  result = operation.(*args)
  Success(result)
rescue *Array(options[:catch]) => e
  e = options[:raise].new(e.message) if options[:raise]
  Failure(e)
end