Module: ExceptionHunter

Extended by:
Tracking
Defined in:
lib/exception_hunter.rb,
lib/exception_hunter/config.rb,
lib/exception_hunter/devise.rb,
lib/exception_hunter/engine.rb,
lib/exception_hunter/version.rb,
lib/exception_hunter/tracking.rb,
lib/exception_hunter/error_reaper.rb,
lib/exception_hunter/data_redacter.rb,
lib/exception_hunter/error_creator.rb,
lib/exception_hunter/notifiers/slack_notifier.rb,
lib/exception_hunter/middleware/request_hunter.rb,
lib/exception_hunter/middleware/request_hunter.rb,
lib/exception_hunter/middleware/sidekiq_hunter.rb,
lib/exception_hunter/user_attributes_collector.rb,
lib/exception_hunter/middleware/delayed_job_hunter.rb,
lib/exception_hunter/notifiers/misconfigured_notifiers.rb,
lib/exception_hunter/notifiers/slack_notifier_serializer.rb

Defined Under Namespace

Modules: Devise, Middleware, Notifiers, Tracking, UserAttributesCollector Classes: Config, DataRedacter, ErrorCreator, ErrorReaper

Constant Summary collapse

VERSION =
'1.1.0'.freeze

Class Method Summary collapse

Class Method Details

.routes(router)

This method returns an undefined value.

Mounts the ExceptionHunter dashboard at /exception_hunter if it's enabled on the current environment.

Examples:

Rails.application.routes.draw do
  ExceptionHunter.routes(self)
end

Parameters:

  • router (ActionDispatch::Routing::Mapper)

    to mount to



41
42
43
44
45
# File 'lib/exception_hunter.rb', line 41

def self.routes(router)
  return unless Config.enabled

  router.mount(ExceptionHunter::Engine, at: 'exception_hunter')
end

.setup(&block)

This method returns an undefined value.

Used to setup ExceptionHunter's configuration it receives a block with the Config singleton class.



26
27
28
29
# File 'lib/exception_hunter.rb', line 26

def self.setup(&block)
  block.call(Config)
  validate_config!
end

.track(exception, custom_data: {}, user: nil) Originally defined in module Tracking

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)