Class: UseCases::StepAdapters::Try

Inherits:
Abstract
  • Object
show all
Defined in:
lib/use_cases/step_adapters/try.rb

Defined Under Namespace

Classes: InvalidReturnValue

Instance Attribute Summary

Attributes inherited from Abstract

#failure, #name, #object, #options

Instance Method Summary collapse

Methods inherited from Abstract

#bind, #call, #callable_args, #callable_args_count, #callable_method, #callable_object, #callable_proc, #external?, #hashed_args, #initialize, #missing?, #pass_option, #previous_input_param_name, #previous_step_result, #selects_external_args?, #with_option

Constructor Details

This class inherits a constructor from UseCases::StepAdapters::Abstract

Instance Method Details

#do_call(*args) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/use_cases/step_adapters/try.rb', line 10

def do_call(*args)
  result = super(*args)
  raise InvalidReturnValue, "The return value should not be a Monad." if result.is_a?(Dry::Monads::Result)

  Success(result)
rescue options[:catch] || StandardError => e
  Failure([options[:failure], options[:failure_message] || e.message])
end