Class: ExceptionNotifier::DetailedSlackNotifier::DetailedSlackNotification

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

Overview

this class builds Slack exception notifications

Instance Method Summary collapse

Constructor Details

#initialize(exception, options = {}) ⇒ DetailedSlackNotification

Returns a new instance of DetailedSlackNotification.



27
28
29
30
31
32
# File 'lib/exception_notifier/detailed_slack_notifier.rb', line 27

def initialize(exception, options = {})
  @exception = exception
  @env = options[:env]
  @data = ((env && env['exception_notifier.exception_data']) || {}).merge(options[:data] || {})
  @timestamp = Time.zone.now
end

Instance Method Details

#attachmentsObject



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/exception_notifier/detailed_slack_notifier.rb', line 41

def attachments
  array = []

  unless background_exception?
    array << session_attachment
    array << request_attachment
  end

  array << backtrace_attachment
  array << data_attachment
end

#messageObject



34
35
36
37
38
39
# File 'lib/exception_notifier/detailed_slack_notifier.rb', line 34

def message
  msg = "#{exception.class.to_s =~ /^[aeiou]/i ? 'An' : 'A'} #{exception.class} occurred"
  msg << "#{background_exception? ? ' in background' : ''} at #{timestamp} :\n"
  msg << "#{exception.message}\n"
  msg
end