exception_notification 4.6.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +30 -0
  3. data/CONTRIBUTING.md +23 -51
  4. data/README.md +65 -31
  5. data/Rakefile +14 -7
  6. data/exception_notification.gemspec +36 -32
  7. data/lib/exception_notification/rack.rb +4 -4
  8. data/lib/exception_notification/rails.rb +2 -2
  9. data/lib/exception_notification/rake.rb +3 -7
  10. data/lib/exception_notification/resque.rb +2 -2
  11. data/lib/exception_notification/sidekiq.rb +8 -23
  12. data/lib/exception_notification/version.rb +1 -1
  13. data/lib/exception_notification.rb +3 -3
  14. data/lib/exception_notifier/datadog_notifier.rb +26 -26
  15. data/lib/exception_notifier/email_notifier.rb +34 -30
  16. data/lib/exception_notifier/google_chat_notifier.rb +9 -9
  17. data/lib/exception_notifier/hipchat_notifier.rb +12 -12
  18. data/lib/exception_notifier/irc_notifier.rb +6 -6
  19. data/lib/exception_notifier/mattermost_notifier.rb +13 -13
  20. data/lib/exception_notifier/modules/error_grouping.rb +5 -5
  21. data/lib/exception_notifier/modules/formatter.rb +12 -12
  22. data/lib/exception_notifier/notifier.rb +3 -3
  23. data/lib/exception_notifier/slack_notifier.rb +16 -16
  24. data/lib/exception_notifier/sns_notifier.rb +9 -9
  25. data/lib/exception_notifier/teams_notifier.rb +61 -57
  26. data/lib/exception_notifier/webhook_notifier.rb +3 -3
  27. data/lib/exception_notifier.rb +27 -26
  28. data/lib/generators/exception_notification/install_generator.rb +7 -7
  29. data/lib/generators/exception_notification/templates/exception_notification.rb.erb +26 -27
  30. metadata +41 -110
  31. data/Appraisals +0 -9
  32. data/Gemfile +0 -5
  33. data/Gemfile.lock +0 -352
  34. data/gemfiles/rails5_2.gemfile +0 -7
  35. data/gemfiles/rails6_0.gemfile +0 -7
  36. data/gemfiles/rails6_1.gemfile +0 -7
  37. data/gemfiles/rails7_0.gemfile +0 -7
  38. data/test/exception_notification/rack_test.rb +0 -106
  39. data/test/exception_notification/rake_test.rb +0 -38
  40. data/test/exception_notification/resque_test.rb +0 -54
  41. data/test/exception_notifier/datadog_notifier_test.rb +0 -153
  42. data/test/exception_notifier/email_notifier_test.rb +0 -351
  43. data/test/exception_notifier/google_chat_notifier_test.rb +0 -185
  44. data/test/exception_notifier/hipchat_notifier_test.rb +0 -218
  45. data/test/exception_notifier/irc_notifier_test.rb +0 -139
  46. data/test/exception_notifier/mattermost_notifier_test.rb +0 -251
  47. data/test/exception_notifier/modules/error_grouping_test.rb +0 -167
  48. data/test/exception_notifier/modules/formatter_test.rb +0 -152
  49. data/test/exception_notifier/sidekiq_test.rb +0 -34
  50. data/test/exception_notifier/slack_notifier_test.rb +0 -229
  51. data/test/exception_notifier/sns_notifier_test.rb +0 -178
  52. data/test/exception_notifier/teams_notifier_test.rb +0 -92
  53. data/test/exception_notifier/webhook_notifier_test.rb +0 -98
  54. data/test/exception_notifier_test.rb +0 -288
  55. data/test/support/exception_notifier_helper.rb +0 -14
  56. data/test/support/views/exception_notifier/_new_bkg_section.html.erb +0 -1
  57. data/test/support/views/exception_notifier/_new_bkg_section.text.erb +0 -1
  58. data/test/support/views/exception_notifier/_new_section.html.erb +0 -1
  59. data/test/support/views/exception_notifier/_new_section.text.erb +0 -1
  60. data/test/test_helper.rb +0 -19
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'exception_notifier'
4
- require 'exception_notification/rack'
5
- require 'exception_notification/version'
3
+ require "exception_notifier"
4
+ require "exception_notification/rack"
5
+ require "exception_notification/version"
6
6
 
7
7
  module ExceptionNotification
8
8
  # Alternative way to setup ExceptionNotification.
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'action_dispatch'
3
+ require "action_dispatch"
4
4
 
5
5
  module ExceptionNotifier
6
6
  class DatadogNotifier < BaseNotifier
7
7
  attr_reader :client,
8
- :default_options
8
+ :default_options
9
9
 
10
10
  def initialize(options)
11
11
  super
@@ -32,10 +32,10 @@ module ExceptionNotifier
32
32
  MAX_TITLE_LENGTH = 120
33
33
  MAX_VALUE_LENGTH = 300
34
34
  MAX_BACKTRACE_SIZE = 3
35
- ALERT_TYPE = 'error'
35
+ ALERT_TYPE = "error"
36
36
 
37
37
  attr_reader :exception,
38
- :options
38
+ :options
39
39
 
40
40
  def initialize(exception, options)
41
41
  @exception = exception
@@ -47,7 +47,7 @@ module ExceptionNotifier
47
47
  end
48
48
 
49
49
  def controller
50
- @controller ||= options[:env] && options[:env]['action_controller.instance']
50
+ @controller ||= options[:env] && options[:env]["action_controller.instance"]
51
51
  end
52
52
 
53
53
  def backtrace
@@ -59,7 +59,7 @@ module ExceptionNotifier
59
59
  end
60
60
 
61
61
  def title_prefix
62
- options[:title_prefix] || ''
62
+ options[:title_prefix] || ""
63
63
  end
64
64
 
65
65
  def event
@@ -85,11 +85,11 @@ module ExceptionNotifier
85
85
  def formatted_body
86
86
  text = []
87
87
 
88
- text << '%%%'
88
+ text << "%%%"
89
89
  text << formatted_request if request
90
90
  text << formatted_session if request
91
91
  text << formatted_backtrace
92
- text << '%%%'
92
+ text << "%%%"
93
93
 
94
94
  text.join("\n")
95
95
  end
@@ -100,24 +100,24 @@ module ExceptionNotifier
100
100
 
101
101
  def formatted_request
102
102
  text = []
103
- text << '### **Request**'
104
- text << formatted_key_value('URL', request.url)
105
- text << formatted_key_value('HTTP Method', request.request_method)
106
- text << formatted_key_value('IP Address', request.remote_ip)
107
- text << formatted_key_value('Parameters', request.filtered_parameters.inspect)
108
- text << formatted_key_value('Timestamp', Time.current)
109
- text << formatted_key_value('Server', Socket.gethostname)
110
- text << formatted_key_value('Rails root', Rails.root) if defined?(Rails) && Rails.respond_to?(:root)
111
- text << formatted_key_value('Process', $PROCESS_ID)
112
- text << '___'
103
+ text << "### **Request**"
104
+ text << formatted_key_value("URL", request.url)
105
+ text << formatted_key_value("HTTP Method", request.request_method)
106
+ text << formatted_key_value("IP Address", request.remote_ip)
107
+ text << formatted_key_value("Parameters", request.filtered_parameters.inspect)
108
+ text << formatted_key_value("Timestamp", Time.current)
109
+ text << formatted_key_value("Server", Socket.gethostname)
110
+ text << formatted_key_value("Rails root", Rails.root) if defined?(Rails) && Rails.respond_to?(:root)
111
+ text << formatted_key_value("Process", $PROCESS_ID)
112
+ text << "___"
113
113
  text.join("\n")
114
114
  end
115
115
 
116
116
  def formatted_session
117
117
  text = []
118
- text << '### **Session**'
119
- text << formatted_key_value('Data', request.session.to_hash)
120
- text << '___'
118
+ text << "### **Session**"
119
+ text << formatted_key_value("Data", request.session.to_hash)
120
+ text << "___"
121
121
  text.join("\n")
122
122
  end
123
123
 
@@ -125,16 +125,16 @@ module ExceptionNotifier
125
125
  size = [backtrace.size, MAX_BACKTRACE_SIZE].min
126
126
 
127
127
  text = []
128
- text << '### **Backtrace**'
129
- text << '````'
128
+ text << "### **Backtrace**"
129
+ text << "````"
130
130
  size.times { |i| text << backtrace[i] }
131
- text << '````'
132
- text << '___'
131
+ text << "````"
132
+ text << "___"
133
133
  text.join("\n")
134
134
  end
135
135
 
136
136
  def truncate(string, max)
137
- string.length > max ? "#{string[0...max]}..." : string
137
+ (string.length > max) ? "#{string[0...max]}..." : string
138
138
  end
139
139
 
140
140
  def inspect_object(object)
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/time'
4
- require 'action_mailer'
5
- require 'action_dispatch'
6
- require 'pp'
3
+ require "active_support/core_ext/time"
4
+ require "action_mailer"
5
+ require "action_dispatch"
6
+ require "pp"
7
7
 
8
8
  module ExceptionNotifier
9
9
  class EmailNotifier < BaseNotifier
10
10
  DEFAULT_OPTIONS = {
11
11
  sender_address: %("Exception Notifier" <exception.notifier@example.com>),
12
12
  exception_recipients: [],
13
- email_prefix: '[ERROR] ',
13
+ email_prefix: "[ERROR] ",
14
14
  email_format: :text,
15
15
  sections: %w[request session environment backtrace],
16
16
  background_sections: %w[backtrace data],
@@ -20,14 +20,18 @@ module ExceptionNotifier
20
20
  delivery_method: nil,
21
21
  mailer_settings: nil,
22
22
  email_headers: {},
23
- mailer_parent: 'ActionMailer::Base',
24
- template_path: 'exception_notifier',
23
+ mailer_parent: "ActionMailer::Base",
24
+ template_path: "exception_notifier",
25
25
  deliver_with: nil
26
26
  }.freeze
27
27
 
28
28
  module Mailer
29
29
  class MissingController
30
- def method_missing(*args, &block); end
30
+ def method_missing(*args, &block)
31
+ end
32
+
33
+ def respond_to_missing?(*args)
34
+ end
31
35
  end
32
36
 
33
37
  def self.extended(base)
@@ -40,18 +44,18 @@ module ExceptionNotifier
40
44
  def exception_notification(env, exception, options = {}, default_options = {})
41
45
  load_custom_views
42
46
 
43
- @env = env
44
- @exception = exception
47
+ @env = env
48
+ @exception = exception
45
49
 
46
- env_options = env['exception_notifier.options'] || {}
47
- @options = default_options.merge(env_options).merge(options)
50
+ env_options = env["exception_notifier.options"] || {}
51
+ @options = default_options.merge(env_options).merge(options)
48
52
 
49
- @kontroller = env['action_controller.instance'] || MissingController.new
50
- @request = ActionDispatch::Request.new(env)
51
- @backtrace = exception.backtrace ? clean_backtrace(exception) : []
52
- @timestamp = Time.current
53
- @sections = @options[:sections]
54
- @data = (env['exception_notifier.exception_data'] || {}).merge(options[:data] || {})
53
+ @kontroller = env["action_controller.instance"] || MissingController.new
54
+ @request = ActionDispatch::Request.new(env)
55
+ @backtrace = exception.backtrace ? clean_backtrace(exception) : []
56
+ @timestamp = Time.current
57
+ @sections = @options[:sections]
58
+ @data = (env["exception_notifier.exception_data"] || {}).merge(options[:data] || {})
55
59
  @sections += %w[data] unless @data.empty?
56
60
 
57
61
  compose_email
@@ -61,11 +65,11 @@ module ExceptionNotifier
61
65
  load_custom_views
62
66
 
63
67
  @exception = exception
64
- @options = default_options.merge(options).symbolize_keys
68
+ @options = default_options.merge(options).symbolize_keys
65
69
  @backtrace = exception.backtrace || []
66
70
  @timestamp = Time.current
67
- @sections = @options[:background_sections]
68
- @data = options[:data] || {}
71
+ @sections = @options[:background_sections]
72
+ @data = options[:data] || {}
69
73
  @env = @kontroller = nil
70
74
 
71
75
  compose_email
@@ -80,7 +84,7 @@ module ExceptionNotifier
80
84
  subject << " (#{@exception.class})"
81
85
  subject << " #{@exception.message.inspect}" if @options[:verbose_subject]
82
86
  subject = EmailNotifier.normalize_digits(subject) if @options[:normalize_subject]
83
- subject.length > 120 ? subject[0...120] + '...' : subject
87
+ (subject.length > 120) ? subject[0...120] + "..." : subject
84
88
  end
85
89
 
86
90
  def include_controller?
@@ -89,14 +93,14 @@ module ExceptionNotifier
89
93
 
90
94
  def set_data_variables
91
95
  @data.each do |name, value|
92
- instance_variable_set("@#{name}", value)
96
+ instance_variable_set(:"@#{name}", value)
93
97
  end
94
98
  end
95
99
 
96
100
  helper_method :inspect_object
97
101
 
98
102
  def truncate(string, max)
99
- string.length > max ? "#{string[0...max]}..." : string
103
+ (string.length > max) ? "#{string[0...max]}..." : string
100
104
  end
101
105
 
102
106
  def inspect_object(object)
@@ -111,7 +115,7 @@ module ExceptionNotifier
111
115
  helper_method :safe_encode
112
116
 
113
117
  def safe_encode(value)
114
- value.encode('utf-8', invalid: :replace, undef: :replace, replace: '_')
118
+ value.encode("utf-8", invalid: :replace, undef: :replace, replace: "_")
115
119
  end
116
120
 
117
121
  def html_mail?
@@ -121,7 +125,7 @@ module ExceptionNotifier
121
125
  def compose_email
122
126
  set_data_variables
123
127
  subject = compose_subject
124
- name = @env.nil? ? 'background_exception_notification' : 'exception_notification'
128
+ name = @env.nil? ? "background_exception_notification" : "exception_notification"
125
129
  exception_recipients = maybe_call(@options[:exception_recipients])
126
130
 
127
131
  headers = {
@@ -145,7 +149,7 @@ module ExceptionNotifier
145
149
  def load_custom_views
146
150
  return unless defined?(Rails) && Rails.respond_to?(:root)
147
151
 
148
- prepend_view_path Rails.root.nil? ? 'app/views' : "#{Rails.root}/app/views"
152
+ prepend_view_path Rails.root.nil? ? "app/views" : "#{Rails.root}/app/views"
149
153
  end
150
154
 
151
155
  def maybe_call(maybe_proc)
@@ -158,8 +162,8 @@ module ExceptionNotifier
158
162
  def initialize(options)
159
163
  super
160
164
 
161
- delivery_method = (options[:delivery_method] || :smtp)
162
- mailer_settings_key = "#{delivery_method}_settings".to_sym
165
+ delivery_method = options[:delivery_method] || :smtp
166
+ mailer_settings_key = :"#{delivery_method}_settings"
163
167
  options[:mailer_settings] = options.delete(mailer_settings_key)
164
168
 
165
169
  @base_options = DEFAULT_OPTIONS.merge(options)
@@ -184,7 +188,7 @@ module ExceptionNotifier
184
188
  end
185
189
 
186
190
  def self.normalize_digits(string)
187
- string.gsub(/[0-9]+/, 'N')
191
+ string.gsub(/[0-9]+/, "N")
188
192
  end
189
193
 
190
194
  private
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'httparty'
3
+ require "httparty"
4
4
 
5
5
  module ExceptionNotifier
6
6
  class GoogleChatNotifier < BaseNotifier
@@ -10,8 +10,8 @@ module ExceptionNotifier
10
10
 
11
11
  HTTParty.post(
12
12
  options[:webhook_url],
13
- body: { text: body(exception, formatter) }.to_json,
14
- headers: { 'Content-Type' => 'application/json' }
13
+ body: {text: body(exception, formatter)}.to_json,
14
+ headers: {"Content-Type" => "application/json"}
15
15
  )
16
16
  end
17
17
 
@@ -21,20 +21,20 @@ module ExceptionNotifier
21
21
  text = [
22
22
  "\nApplication: *#{formatter.app_name}*",
23
23
  formatter.subtitle,
24
- '',
24
+ "",
25
25
  formatter.title,
26
- "*#{exception.message.tr('`', "'")}*"
26
+ "*#{exception.message.tr("`", "'")}*"
27
27
  ]
28
28
 
29
29
  if (request = formatter.request_message.presence)
30
- text << ''
31
- text << '*Request:*'
30
+ text << ""
31
+ text << "*Request:*"
32
32
  text << request
33
33
  end
34
34
 
35
35
  if (backtrace = formatter.backtrace_message.presence)
36
- text << ''
37
- text << '*Backtrace:*'
36
+ text << ""
37
+ text << "*Backtrace:*"
38
38
  text << backtrace
39
39
  end
40
40
 
@@ -9,26 +9,26 @@ module ExceptionNotifier
9
9
  def initialize(options)
10
10
  super
11
11
  begin
12
- api_token = options.delete(:api_token)
13
- room_name = options.delete(:room_name)
14
- opts = {
15
- api_version: options.delete(:api_version) || 'v1'
12
+ api_token = options.delete(:api_token)
13
+ room_name = options.delete(:room_name)
14
+ opts = {
15
+ api_version: options.delete(:api_version) || "v1"
16
16
  }
17
17
  opts[:server_url] = options.delete(:server_url) if options[:server_url]
18
- @from = options.delete(:from) || 'Exception'
19
- @room = HipChat::Client.new(api_token, opts)[room_name]
18
+ @from = options.delete(:from) || "Exception"
19
+ @room = HipChat::Client.new(api_token, opts)[room_name]
20
20
  @message_template = options.delete(:message_template) || lambda { |exception, errors_count|
21
21
  msg = if errors_count > 1
22
- "The exception occurred #{errors_count} times: '#{Rack::Utils.escape_html(exception.message)}'"
23
- else
24
- "A new exception occurred: '#{Rack::Utils.escape_html(exception.message)}'"
25
- end
22
+ "The exception occurred #{errors_count} times: '#{Rack::Utils.escape_html(exception.message)}'"
23
+ else
24
+ "A new exception occurred: '#{Rack::Utils.escape_html(exception.message)}'"
25
+ end
26
26
  msg += " on '#{exception.backtrace.first}'" if exception.backtrace
27
27
  msg
28
28
  }
29
29
  @message_options = options
30
- @message_options[:color] ||= 'red'
31
- rescue StandardError
30
+ @message_options[:color] ||= "red"
31
+ rescue
32
32
  @room = nil
33
33
  end
34
34
  end
@@ -18,7 +18,7 @@ module ExceptionNotifier
18
18
  return unless active?
19
19
 
20
20
  send_notice(exception, options, message) do |msg, _|
21
- send_message([*@config.prefix, *msg].join(' '))
21
+ send_message([*@config.prefix, *msg].join(" "))
22
22
  end
23
23
  end
24
24
 
@@ -29,20 +29,20 @@ module ExceptionNotifier
29
29
  private
30
30
 
31
31
  def parse_options(options)
32
- nick = options.fetch(:nick, 'ExceptionNotifierBot')
32
+ nick = options.fetch(:nick, "ExceptionNotifierBot")
33
33
  password = options[:password] ? ":#{options[:password]}" : nil
34
34
  domain = options.fetch(:domain, nil)
35
35
  port = options[:port] ? ":#{options[:port]}" : nil
36
- channel = options.fetch(:channel, '#log')
36
+ channel = options.fetch(:channel, "#log")
37
37
  notice = options.fetch(:notice, false)
38
38
  ssl = options.fetch(:ssl, false)
39
39
  join = options.fetch(:join, false)
40
40
  uri = "irc://#{nick}#{password}@#{domain}#{port}/#{channel}"
41
41
  prefix = options.fetch(:prefix, nil)
42
- recipients = options[:recipients] ? options[:recipients].join(', ') + ':' : nil
42
+ recipients = options[:recipients] ? options[:recipients].join(", ") + ":" : nil
43
43
 
44
- @config.prefix = [*prefix, *recipients].join(' ')
45
- @config.irc = { uri: uri, ssl: ssl, notice: notice, join: join }
44
+ @config.prefix = [*prefix, *recipients].join(" ")
45
+ @config.irc = {uri: uri, ssl: ssl, notice: notice, join: join}
46
46
  end
47
47
 
48
48
  def active?
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'httparty'
3
+ require "httparty"
4
4
 
5
5
  module ExceptionNotifier
6
6
  class MattermostNotifier < BaseNotifier
@@ -16,7 +16,7 @@ module ExceptionNotifier
16
16
 
17
17
  payload = {
18
18
  text: message_text.compact.join("\n"),
19
- username: options[:username] || 'Exception Notifier'
19
+ username: options[:username] || "Exception Notifier"
20
20
  }
21
21
 
22
22
  payload[:icon_url] = options[:avatar] if options[:avatar]
@@ -29,7 +29,7 @@ module ExceptionNotifier
29
29
 
30
30
  httparty_options[:body] = payload.to_json
31
31
  httparty_options[:headers] ||= {}
32
- httparty_options[:headers]['Content-Type'] = 'application/json'
32
+ httparty_options[:headers]["Content-Type"] = "application/json"
33
33
 
34
34
  HTTParty.post(options[:webhook_url], httparty_options)
35
35
  end
@@ -40,24 +40,24 @@ module ExceptionNotifier
40
40
 
41
41
  def message_text
42
42
  text = [
43
- '@channel',
43
+ "@channel",
44
44
  "### #{formatter.title}",
45
45
  formatter.subtitle,
46
46
  "*#{@exception.message}*"
47
47
  ]
48
48
 
49
49
  if (request = formatter.request_message.presence)
50
- text << '### Request'
50
+ text << "### Request"
51
51
  text << request
52
52
  end
53
53
 
54
54
  if (backtrace = formatter.backtrace_message.presence)
55
- text << '### Backtrace'
55
+ text << "### Backtrace"
56
56
  text << backtrace
57
57
  end
58
58
 
59
- if (exception_data = @env['exception_notifier.exception_data'])
60
- text << '### Data'
59
+ if (exception_data = @env["exception_notifier.exception_data"])
60
+ text << "### Data"
61
61
  data_string = exception_data.map { |k, v| "* #{k} : #{v}" }.join("\n")
62
62
  text << "```\n#{data_string}\n```"
63
63
  end
@@ -68,12 +68,12 @@ module ExceptionNotifier
68
68
  end
69
69
 
70
70
  def message_issue_link
71
- link = [@gitlab_url, formatter.app_name, 'issues', 'new'].join('/')
71
+ link = [@gitlab_url, formatter.app_name, "issues", "new"].join("/")
72
72
  params = {
73
- 'issue[title]' => ['[BUG] Error 500 :',
74
- formatter.controller_and_action || '',
75
- "(#{@exception.class})",
76
- @exception.message].compact.join(' ')
73
+ "issue[title]" => ["[BUG] Error 500 :",
74
+ formatter.controller_and_action || "",
75
+ "(#{@exception.class})",
76
+ @exception.message].compact.join(" ")
77
77
  }.to_query
78
78
 
79
79
  "[Create an issue](#{link}/?#{params})"
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support'
4
- require 'active_support/core_ext/numeric/time'
5
- require 'active_support/concern'
3
+ require "active_support"
4
+ require "active_support/core_ext/numeric/time"
5
+ require "active_support/concern"
6
6
 
7
7
  module ExceptionNotifier
8
8
  module ErrorGrouping
@@ -31,7 +31,7 @@ module ExceptionNotifier
31
31
  count =
32
32
  begin
33
33
  error_grouping_cache.read(error_key)
34
- rescue StandardError => e
34
+ rescue => e
35
35
  log_cache_error(error_grouping_cache, e, :read)
36
36
  fallback_cache_store.read(error_key)
37
37
  end
@@ -41,7 +41,7 @@ module ExceptionNotifier
41
41
 
42
42
  def save_error_count(error_key, count)
43
43
  error_grouping_cache.write(error_key, count, expires_in: error_grouping_period)
44
- rescue StandardError => e
44
+ rescue => e
45
45
  log_cache_error(error_grouping_cache, e, :write)
46
46
  fallback_cache_store.write(error_key, count, expires_in: error_grouping_period)
47
47
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/time'
4
- require 'action_dispatch'
3
+ require "active_support/core_ext/time"
4
+ require "action_dispatch"
5
5
 
6
6
  module ExceptionNotifier
7
7
  class Formatter
@@ -27,7 +27,7 @@ module ExceptionNotifier
27
27
  if env
28
28
  "⚠️ Error occurred in #{env} ⚠️"
29
29
  else
30
- '⚠️ Error occurred ⚠️'
30
+ "⚠️ Error occurred ⚠️"
31
31
  end
32
32
  end
33
33
 
@@ -38,10 +38,10 @@ module ExceptionNotifier
38
38
  #
39
39
  def subtitle
40
40
  errors_text = if errors_count > 1
41
- errors_count
42
- else
43
- exception.class.to_s =~ /^[aeiou]/i ? 'An' : 'A'
44
- end
41
+ errors_count
42
+ else
43
+ /^[aeiou]/i.match?(exception.class.to_s) ? "An" : "A"
44
+ end
45
45
 
46
46
  in_action = " in *#{controller_and_action}*" if controller
47
47
 
@@ -64,13 +64,13 @@ module ExceptionNotifier
64
64
  return unless request
65
65
 
66
66
  [
67
- '```',
67
+ "```",
68
68
  "* url : #{request.original_url}",
69
69
  "* http_method : #{request.method}",
70
70
  "* ip_address : #{request.remote_ip}",
71
71
  "* parameters : #{request.filtered_parameters}",
72
72
  "* timestamp : #{Time.current}",
73
- '```'
73
+ "```"
74
74
  ].join("\n")
75
75
  end
76
76
 
@@ -90,9 +90,9 @@ module ExceptionNotifier
90
90
 
91
91
  text = []
92
92
 
93
- text << '```'
93
+ text << "```"
94
94
  backtrace.first(3).each { |line| text << "* #{line}" }
95
- text << '```'
95
+ text << "```"
96
96
 
97
97
  text.join("\n")
98
98
  end
@@ -119,7 +119,7 @@ module ExceptionNotifier
119
119
  end
120
120
 
121
121
  def controller
122
- env['action_controller.instance'] if env
122
+ env["action_controller.instance"] if env
123
123
  end
124
124
  end
125
125
  end
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/deprecation'
3
+ require "active_support/deprecation"
4
4
 
5
5
  module ExceptionNotifier
6
6
  class Notifier
7
7
  def self.exception_notification(env, exception, options = {})
8
8
  ActiveSupport::Deprecation.warn(
9
- 'Please use ExceptionNotifier.notify_exception(exception, options.merge(env: env)).'
9
+ "Please use ExceptionNotifier.notify_exception(exception, options.merge(env: env))."
10
10
  )
11
11
  ExceptionNotifier.registered_exception_notifier(:email).create_email(exception, options.merge(env: env))
12
12
  end
13
13
 
14
14
  def self.background_exception_notification(exception, options = {})
15
- ActiveSupport::Deprecation.warn 'Please use ExceptionNotifier.notify_exception(exception, options).'
15
+ ActiveSupport::Deprecation.warn "Please use ExceptionNotifier.notify_exception(exception, options)."
16
16
  ExceptionNotifier.registered_exception_notifier(:email).create_email(exception, options)
17
17
  end
18
18
  end