module ExceptionTransformer::InstanceMethods

Public Instance Methods

handle_exceptions(group = :default, **opts) { || ... } click to toggle source
# File lib/exception_transformer.rb, line 84
def handle_exceptions(group = :default, **opts)
  # NOTE: `base_label` returns the label of this frame without decoration,
  # i.e. if `label` was 'block in test', then `base_label` would be `test`.

  calling_method = caller_locations(1, 1)[0].base_label
  transformer    = self.class.find_exception_transformer(group)

  result = yield

  transformer.after_yield(self, result, calling_method, **opts)

  result
rescue => e
  transformer.after_rescue(self, e, calling_method, **opts)
end