Module: Trailblazer::Macro::Rescue

Defined in:
lib/trailblazer/macro/rescue.rb

Overview

TODO: remove me in 2.2.

Class Method Summary collapse

Class Method Details

.deprecate_positional_handler_signature(handler) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/trailblazer/macro/rescue.rb', line 32

def self.deprecate_positional_handler_signature(handler)
  return handler if handler.is_a?(Symbol) # can't do nothing about this.
  return handler if handler.method(:call).arity != 2 # means (exception, (ctx, flow_options), *, &block), "new style"

  ->(exception, (ctx, flow_options), **circuit_options, &block) do
    warn "[Trailblazer] Rescue handlers have a new signature: (exception, *, &block)"
    handler.(exception, ctx, &block)
  end
end