Class: Strobe::ExceptionNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/strobe/exception_notifier.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(e, options = {}) ⇒ ExceptionNotifier

Returns a new instance of ExceptionNotifier.



19
20
21
22
23
24
# File 'lib/strobe/exception_notifier.rb', line 19

def initialize(e, options = {})
  @exception = e
  @options   = options

  extract_action
end

Class Attribute Details

.enabledObject Also known as: enabled?

Returns the value of attribute enabled.



4
5
6
# File 'lib/strobe/exception_notifier.rb', line 4

def enabled
  @enabled
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



17
18
19
# File 'lib/strobe/exception_notifier.rb', line 17

def action
  @action
end

#exceptionObject (readonly)

Returns the value of attribute exception.



17
18
19
# File 'lib/strobe/exception_notifier.rb', line 17

def exception
  @exception
end

Class Method Details

.notify(e, options = {}) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/strobe/exception_notifier.rb', line 7

def notify(e, options = {})
  return unless enabled?
  message = "Something went wrong with the request. Send an error report to Strobe? [Yn] "
  if options[:force] || Strobe::CLI::Input.new.agree(message)
    new(e, options).notify
  end
end

Instance Method Details

#notifyObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/strobe/exception_notifier.rb', line 26

def notify
  params = {
    :error_class   => error_class,
    :error_message => error_message,
    :strobe_action => action,
    :parameters    => parameters,
    :backtrace     => exception.backtrace.join("\n")
  }
  Strobe.connection.post "/errors", params
end