Method: Immunio::ExceptionHandler#unwrap_exception

Defined in:
lib/immunio/plugins/exception_handler.rb

#unwrap_exception(e) ⇒ Object

Unwrap the innermost original exception.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/immunio/plugins/exception_handler.rb', line 48

def unwrap_exception(e)
  if Rails::VERSION::MAJOR > 4
    while e.respond_to?(:cause) && e.cause.is_a?(Exception)
      e = e.cause
    end
  else
    while e.respond_to?(:original_exception) && e.original_exception.is_a?(Exception)
      e = e.original_exception
    end
  end
  e
end