Module: ExceptionTransformer::InstanceMethods

Defined in:
lib/exception_transformer.rb

Instance Method Summary collapse

Instance Method Details

#handle_exceptions(group = :default, **opts) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 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