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

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

Overview

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.

API:

  • private

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.

API:

  • private



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]) => exception
  exception = options[:raise].new(exception.message) if options[:raise]
  Failure(exception)
end