Module: Excom::Plugins::Rescue

Defined in:
lib/excom/plugins/rescue.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.used(service_class) ⇒ Object



5
6
7
8
# File 'lib/excom/plugins/rescue.rb', line 5

def self.used(service_class, *)
  service_class.use(:status) unless service_class.using?(:status)
  service_class.add_execution_prop :error
end

Instance Method Details

#errorObject



21
22
23
# File 'lib/excom/plugins/rescue.rb', line 21

def error
  state.error
end

#error?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/excom/plugins/rescue.rb', line 25

def error?
  status == :error
end

#execute(**opts) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/excom/plugins/rescue.rb', line 10

def execute(**opts)
  rezcue = opts.delete(:rescue)
  super
rescue StandardError => error
  clear_execution_state!
  failure!(:error)
  state.error = error
  raise error unless rezcue
  self
end