module Trailblazer::Macro::Rescue

TODO: remove me in 2.2.

Public Class Methods

deprecate_positional_handler_signature(handler) click to toggle source
# File lib/trailblazer/macro/rescue.rb, line 30
def self.deprecate_positional_handler_signature(handler)
  return handler if handler.is_a?(Symbol) # can't do nutting about this.

  arity = handler.is_a?(Class) ? handler.method(:call).arity : handler.arity

  return handler if 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