Module: ExceptionHunter::Tracking

Included in:
ExceptionHunter
Defined in:
lib/exception_hunter/tracking.rb

Overview

Mixin used to track manual exceptions.

Instance Method Summary collapse

Instance Method Details

#track(exception, custom_data: {}, user: nil) ⇒ void

This method returns an undefined value.

Used to manually track errors in cases where raising might not be adequate and but some insight is desired.

Examples:

Track the else clause on a case

case user.status
when :active then do_something()
when :inactive then do_something_else()
else
  ExceptionHunter.track(StandardError.new("User with unknown status"),
                                          custom_data: { status: user.status },
                                          user: user)
end

Parameters:

  • exception (Exception)

    to track.

  • custom_data (Hash) (defaults to: {})

    to include and help debug the error. (optional)

  • user (User) (defaults to: nil)

    in the current session. (optional)



21
22
23
24
25
26
27
28
29
# File 'lib/exception_hunter/tracking.rb', line 21

def track(exception, custom_data: {}, user: nil)
  if open_transactions?
    create_error_within_new_thread(exception, custom_data, user)
  else
    create_error(exception, custom_data, user)
  end

  nil
end