rollbar 2.23.2 → 3.3.0

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +25 -0
  3. data/.github/workflows/ci.yml +118 -0
  4. data/.rubocop.yml +85 -34
  5. data/Gemfile +22 -22
  6. data/README.md +11 -9
  7. data/data/rollbar.snippet.js +1 -1
  8. data/docs/configuration.md +8 -0
  9. data/gemfiles/rails30.gemfile +18 -35
  10. data/gemfiles/rails31.gemfile +21 -37
  11. data/gemfiles/rails32.gemfile +14 -31
  12. data/gemfiles/rails40.gemfile +13 -32
  13. data/gemfiles/rails41.gemfile +12 -31
  14. data/gemfiles/rails42.gemfile +12 -35
  15. data/gemfiles/rails50.gemfile +17 -29
  16. data/gemfiles/rails51.gemfile +17 -29
  17. data/gemfiles/rails52.gemfile +7 -14
  18. data/gemfiles/rails60.gemfile +7 -20
  19. data/gemfiles/rails61.gemfile +54 -0
  20. data/lib/generators/rollbar/rollbar_generator.rb +18 -14
  21. data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +0 -0
  22. data/lib/rails/rollbar_runner.rb +15 -6
  23. data/lib/rollbar/capistrano.rb +17 -9
  24. data/lib/rollbar/capistrano3.rb +8 -2
  25. data/lib/rollbar/capistrano_tasks.rb +44 -8
  26. data/lib/rollbar/configuration.rb +128 -84
  27. data/lib/rollbar/delay/shoryuken.rb +4 -3
  28. data/lib/rollbar/delay/sidekiq.rb +3 -1
  29. data/lib/rollbar/delay/sucker_punch.rb +1 -2
  30. data/lib/rollbar/delay/thread.rb +3 -2
  31. data/lib/rollbar/deploy.rb +8 -7
  32. data/lib/rollbar/encoding/encoder.rb +10 -3
  33. data/lib/rollbar/exception_reporter.rb +17 -8
  34. data/lib/rollbar/item/backtrace.rb +11 -9
  35. data/lib/rollbar/item/frame.rb +6 -5
  36. data/lib/rollbar/item/locals.rb +3 -2
  37. data/lib/rollbar/item.rb +68 -40
  38. data/lib/rollbar/json.rb +2 -1
  39. data/lib/rollbar/language_support.rb +0 -6
  40. data/lib/rollbar/lazy_store.rb +3 -7
  41. data/lib/rollbar/logger.rb +2 -0
  42. data/lib/rollbar/logger_proxy.rb +3 -1
  43. data/lib/rollbar/middleware/js.rb +64 -37
  44. data/lib/rollbar/middleware/rack/builder.rb +3 -3
  45. data/lib/rollbar/middleware/rack/test_session.rb +3 -3
  46. data/lib/rollbar/middleware/rack.rb +4 -4
  47. data/lib/rollbar/middleware/rails/rollbar.rb +9 -6
  48. data/lib/rollbar/middleware/rails/show_exceptions.rb +8 -4
  49. data/lib/rollbar/notifier/trace_with_bindings.rb +4 -2
  50. data/lib/rollbar/notifier.rb +272 -159
  51. data/lib/rollbar/plugin.rb +8 -8
  52. data/lib/rollbar/plugins/active_job.rb +11 -2
  53. data/lib/rollbar/plugins/delayed_job/plugin.rb +19 -2
  54. data/lib/rollbar/plugins/goalie.rb +27 -16
  55. data/lib/rollbar/plugins/rails/controller_methods.rb +18 -14
  56. data/lib/rollbar/plugins/rails/railtie30.rb +2 -1
  57. data/lib/rollbar/plugins/rails/railtie32.rb +2 -1
  58. data/lib/rollbar/plugins/rails/railtie_mixin.rb +2 -2
  59. data/lib/rollbar/plugins/rails.rb +5 -2
  60. data/lib/rollbar/plugins/rake.rb +2 -1
  61. data/lib/rollbar/plugins/sidekiq/plugin.rb +37 -20
  62. data/lib/rollbar/plugins/sidekiq.rb +1 -1
  63. data/lib/rollbar/plugins/thread.rb +8 -7
  64. data/lib/rollbar/plugins/validations.rb +3 -1
  65. data/lib/rollbar/rake_tasks.rb +1 -2
  66. data/lib/rollbar/request_data_extractor.rb +43 -16
  67. data/lib/rollbar/rollbar_test.rb +9 -118
  68. data/lib/rollbar/scrubbers/params.rb +13 -7
  69. data/lib/rollbar/scrubbers/url.rb +56 -17
  70. data/lib/rollbar/scrubbers.rb +1 -1
  71. data/lib/rollbar/truncation/remove_any_key_strategy.rb +4 -1
  72. data/lib/rollbar/truncation/remove_extra_strategy.rb +3 -1
  73. data/lib/rollbar/util/hash.rb +14 -7
  74. data/lib/rollbar/util/ip_anonymizer.rb +1 -1
  75. data/lib/rollbar/util.rb +19 -13
  76. data/lib/rollbar/version.rb +1 -1
  77. data/lib/rollbar.rb +12 -7
  78. data/lib/tasks/benchmark.rake +2 -1
  79. data/rollbar.gemspec +5 -2
  80. data/spec/support/rollbar_api.rb +67 -0
  81. metadata +9 -6
  82. data/.travis.yml +0 -284
@@ -4,74 +4,82 @@ module Rollbar
4
4
  class Configuration
5
5
  SEND_EXTRA_FRAME_DATA_OPTIONS = [:none, :app, :all].freeze
6
6
 
7
- attr_accessor :access_token
8
- attr_accessor :async_handler
9
- attr_accessor :branch
10
- attr_reader :before_process
11
- attr_accessor :capture_uncaught
12
- attr_accessor :code_version
13
- attr_accessor :custom_data_method
14
- attr_accessor :delayed_job_enabled
15
- attr_accessor :default_logger
16
- attr_reader :logger_level
17
- attr_accessor :disable_monkey_patch
18
- attr_accessor :disable_rack_monkey_patch
19
- attr_accessor :disable_core_monkey_patch
20
- attr_accessor :enable_error_context
21
- attr_accessor :dj_threshold
22
- attr_accessor :enabled
23
- attr_accessor :endpoint
24
- attr_accessor :environment
25
- attr_accessor :exception_level_filters
26
- attr_accessor :failover_handlers
27
- attr_accessor :filepath
28
- attr_accessor :framework
29
- attr_accessor :ignored_person_ids
30
- attr_accessor :host
31
- attr_accessor :locals
32
- attr_writer :logger
33
- attr_accessor :payload_options
34
- attr_accessor :person_method
35
- attr_accessor :person_id_method
36
- attr_accessor :person_username_method
37
- attr_accessor :person_email_method
38
- attr_accessor :populate_empty_backtraces
39
- attr_accessor :report_dj_data
40
- attr_accessor :open_timeout
41
- attr_accessor :request_timeout
42
- attr_accessor :net_retries
43
- attr_accessor :root
44
- attr_accessor :js_options
45
- attr_accessor :js_enabled
46
- attr_accessor :safely
47
- attr_accessor :scrub_fields
48
- attr_accessor :scrub_user
49
- attr_accessor :scrub_password
50
- attr_accessor :scrub_whitelist
51
- attr_accessor :collect_user_ip
52
- attr_accessor :anonymize_user_ip
53
- attr_accessor :user_ip_obfuscator_secret
54
- attr_accessor :randomize_scrub_length
55
- attr_accessor :uncaught_exception_level
56
- attr_accessor :scrub_headers
57
- attr_accessor :sidekiq_threshold
58
- attr_reader :transform
59
- attr_accessor :verify_ssl_peer
60
- attr_accessor :use_async
61
- attr_accessor :async_json_payload
62
- attr_reader :use_eventmachine
63
- attr_accessor :web_base
64
- attr_accessor :write_to_file
65
- attr_reader :send_extra_frame_data
66
- attr_accessor :use_exception_level_filters_default
67
- attr_accessor :proxy
68
- attr_accessor :raise_on_error
69
- attr_accessor :transmit
70
- attr_accessor :log_payload
71
- attr_accessor :backtrace_cleaner
72
-
73
- attr_reader :project_gem_paths
74
- attr_accessor :configured_options
7
+ attr_accessor :access_token,
8
+ :anonymize_user_ip,
9
+ :async_handler,
10
+ :async_json_payload,
11
+ :async_skip_report_handler,
12
+ :backtrace_cleaner,
13
+ :branch,
14
+ :capture_uncaught,
15
+ :code_version,
16
+ :collect_user_ip,
17
+ :configured_options,
18
+ :custom_data_method,
19
+ :default_logger,
20
+ :delayed_job_enabled,
21
+ :disable_core_monkey_patch,
22
+ :disable_monkey_patch,
23
+ :disable_rack_monkey_patch,
24
+ :dj_threshold,
25
+ :enable_error_context,
26
+ :enabled,
27
+ :endpoint,
28
+ :environment,
29
+ :exception_level_filters,
30
+ :failover_handlers,
31
+ :filepath,
32
+ :files_processed_duration,
33
+ :files_processed_enabled,
34
+ :files_processed_size,
35
+ :files_with_pid_name_enabled,
36
+ :framework,
37
+ :ignore_internal_errors,
38
+ :ignored_person_ids,
39
+ :js_enabled,
40
+ :js_options,
41
+ :host,
42
+ :locals,
43
+ :log_payload,
44
+ :net_retries,
45
+ :open_timeout,
46
+ :payload_options,
47
+ :person_email_method,
48
+ :person_id_method,
49
+ :person_method,
50
+ :person_username_method,
51
+ :populate_empty_backtraces,
52
+ :proxy,
53
+ :raise_on_error,
54
+ :randomize_scrub_length,
55
+ :report_dj_data,
56
+ :request_timeout,
57
+ :root,
58
+ :safely,
59
+ :scrub_fields,
60
+ :scrub_password,
61
+ :scrub_user,
62
+ :scrub_whitelist,
63
+ :transmit,
64
+ :uncaught_exception_level,
65
+ :user_ip_obfuscator_secret,
66
+ :user_ip_rack_env_key,
67
+ :scrub_headers,
68
+ :sidekiq_threshold,
69
+ :sidekiq_use_scoped_block,
70
+ :use_async,
71
+ :use_exception_level_filters_default,
72
+ :use_payload_access_token,
73
+ :verify_ssl_peer,
74
+ :web_base,
75
+ :write_to_file
76
+ attr_reader :before_process,
77
+ :logger_level,
78
+ :project_gem_paths,
79
+ :send_extra_frame_data,
80
+ :transform,
81
+ :use_eventmachine
82
+ attr_writer :logger # seconds # bytes
75
83
 
76
84
  alias safely? safely
77
85
 
@@ -79,12 +87,14 @@ module Rollbar
79
87
  DEFAULT_WEB_BASE = 'https://rollbar.com'.freeze
80
88
 
81
89
  def initialize
90
+ @access_token = nil
82
91
  @async_handler = nil
83
92
  @before_process = []
93
+ @branch = nil
84
94
  @capture_uncaught = nil
85
95
  @code_version = nil
86
96
  @custom_data_method = nil
87
- @default_logger = lambda { ::Logger.new(STDERR) }
97
+ @default_logger = lambda { ::Logger.new($stderr) }
88
98
  @logger_level = :info
89
99
  @delayed_job_enabled = true
90
100
  @disable_monkey_patch = false
@@ -92,6 +102,7 @@ module Rollbar
92
102
  @disable_rack_monkey_patch = false
93
103
  @enable_error_context = true
94
104
  @dj_threshold = 0
105
+ @async_skip_report_handler = nil
95
106
  @enabled = nil # set to true when configure is called
96
107
  @endpoint = DEFAULT_ENDPOINT
97
108
  @environment = nil
@@ -102,7 +113,13 @@ module Rollbar
102
113
  }
103
114
  @failover_handlers = []
104
115
  @framework = 'Plain'
116
+ @ignore_internal_errors = [
117
+ 'Net::ReadTimeout',
118
+ 'Net::OpenTimeout',
119
+ 'SocketError'
120
+ ]
105
121
  @ignored_person_ids = []
122
+ @host = nil
106
123
  @payload_options = {}
107
124
  @person_method = 'current_user'
108
125
  @person_id_method = 'id'
@@ -114,6 +131,7 @@ module Rollbar
114
131
  @open_timeout = 3
115
132
  @request_timeout = 3
116
133
  @net_retries = 3
134
+ @root = nil
117
135
  @js_enabled = false
118
136
  @js_options = {}
119
137
  @locals = {}
@@ -127,6 +145,7 @@ module Rollbar
127
145
  @uncaught_exception_level = 'error'
128
146
  @scrub_headers = ['Authorization']
129
147
  @sidekiq_threshold = 0
148
+ @sidekiq_use_scoped_block = false
130
149
  @safely = false
131
150
  @transform = []
132
151
  @use_async = false
@@ -134,7 +153,6 @@ module Rollbar
134
153
  @use_eventmachine = false
135
154
  @verify_ssl_peer = true
136
155
  @web_base = DEFAULT_WEB_BASE
137
- @write_to_file = false
138
156
  @send_extra_frame_data = :none
139
157
  @project_gem_paths = []
140
158
  @use_exception_level_filters_default = false
@@ -144,12 +162,22 @@ module Rollbar
144
162
  @log_payload = false
145
163
  @collect_user_ip = true
146
164
  @anonymize_user_ip = false
165
+ @user_ip_obfuscator_secret = nil
166
+ @user_ip_rack_env_key = nil
147
167
  @backtrace_cleaner = nil
148
168
  @hooks = {
149
169
  :on_error_response => nil, # params: response
150
170
  :on_report_internal_error => nil # params: exception
151
171
  }
152
172
 
173
+ @write_to_file = false
174
+ @filepath = nil
175
+ @files_with_pid_name_enabled = false
176
+ @files_processed_enabled = false
177
+ @files_processed_duration = 60
178
+ @files_processed_size = 5 * 1000 * 1000
179
+ @use_payload_access_token = false
180
+
153
181
  @configured_options = ConfiguredOptions.new(self)
154
182
  end
155
183
 
@@ -192,7 +220,8 @@ module Rollbar
192
220
  def use_active_job(options = {})
193
221
  require 'rollbar/delay/active_job'
194
222
 
195
- Rollbar::Delay::ActiveJob.queue_as(options[:queue] || Rollbar::Delay::ActiveJob.default_queue_name)
223
+ Rollbar::Delay::ActiveJob.queue_as(options[:queue] ||
224
+ Rollbar::Delay::ActiveJob.default_queue_name)
196
225
 
197
226
  @use_async = true
198
227
  @async_handler = Rollbar::Delay::ActiveJob
@@ -232,8 +261,13 @@ module Rollbar
232
261
  end
233
262
 
234
263
  def use_sidekiq=(value)
235
- deprecation_message = '#use_sidekiq=(value) has been deprecated in favor of #use_sidekiq(options = {}). Please update your rollbar configuration.'
236
- defined?(ActiveSupport) ? ActiveSupport::Deprecation.warn(deprecation_message) : puts(deprecation_message)
264
+ deprecation_message = '#use_sidekiq=(value) has been deprecated in favor ' \
265
+ 'of #use_sidekiq(options = {}). Please update your rollbar configuration.'
266
+ if defined?(ActiveSupport)
267
+ ActiveSupport::Deprecation.warn(deprecation_message)
268
+ else
269
+ puts(deprecation_message)
270
+ end
237
271
 
238
272
  value.is_a?(Hash) ? use_sidekiq(value) : use_sidekiq
239
273
  end
@@ -252,8 +286,13 @@ module Rollbar
252
286
  end
253
287
 
254
288
  def use_sucker_punch=(_value)
255
- deprecation_message = '#use_sucker_punch=(value) has been deprecated in favor of #use_sucker_punch. Please update your rollbar configuration.'
256
- defined?(ActiveSupport) ? ActiveSupport::Deprecation.warn(deprecation_message) : puts(deprecation_message)
289
+ deprecation_message = '#use_sucker_punch=(value) has been deprecated in ' \
290
+ 'favor of #use_sucker_punch. Please update your rollbar configuration.'
291
+ if defined?(ActiveSupport)
292
+ ActiveSupport::Deprecation.warn(deprecation_message)
293
+ else
294
+ puts(deprecation_message)
295
+ end
257
296
 
258
297
  use_sucker_punch
259
298
  end
@@ -284,7 +323,9 @@ module Rollbar
284
323
 
285
324
  def send_extra_frame_data=(value)
286
325
  unless SEND_EXTRA_FRAME_DATA_OPTIONS.include?(value)
287
- logger.warning("Wrong 'send_extra_frame_data' value, :none, :app or :full is expected")
326
+ logger.warning(
327
+ "Wrong 'send_extra_frame_data' value, :none, :app or :full is expected"
328
+ )
288
329
 
289
330
  return
290
331
  end
@@ -310,14 +351,14 @@ module Rollbar
310
351
  end
311
352
 
312
353
  def hook(symbol, &block)
313
- if @hooks.key?(symbol)
314
- if block_given?
315
- @hooks[symbol] = block
316
- else
317
- @hooks[symbol]
318
- end
354
+ unless @hooks.key?(symbol)
355
+ raise StandardError, "Hook :#{symbol} is not supported by Rollbar SDK."
356
+ end
357
+
358
+ if block_given?
359
+ @hooks[symbol] = block
319
360
  else
320
- raise StandardError, 'Hook :' + symbol.to_s + ' is not supported by Rollbar SDK.'
361
+ @hooks[symbol]
321
362
  end
322
363
  end
323
364
 
@@ -338,7 +379,10 @@ module Rollbar
338
379
  return super unless configuration.respond_to?(method)
339
380
 
340
381
  method_string = method.to_s
341
- configured[method_string.chomp('=').to_sym] = args.first if method_string.end_with?('=')
382
+ if method_string.end_with?('=')
383
+ configured[method_string.chomp('=').to_sym] =
384
+ args.first
385
+ end
342
386
 
343
387
  configuration.send(method, *args, &block)
344
388
  end
@@ -2,9 +2,10 @@ require 'shoryuken'
2
2
 
3
3
  module Rollbar
4
4
  module Delay
5
- # Following class allows to send rollbars using Sho-ryu-ken as a background jobs processor.
6
- # see the queue_name method which states that your queues needs to be names as "rollbar_ENVIRONMENT".
7
- # retry intervals will be used to retry sending the same message again if failed before.
5
+ # Following class allows to send rollbars using Sho-ryu-ken as a background
6
+ # jobs processor. See the queue_name method which states that your queues
7
+ # needs to be names as "rollbar_ENVIRONMENT". Retry intervals will be used
8
+ # to retry sending the same message again if failed before.
8
9
  class Shoryuken
9
10
  include ::Shoryuken::Worker
10
11
 
@@ -10,7 +10,9 @@ module Rollbar
10
10
  end
11
11
 
12
12
  def call(payload)
13
- raise StandardError, 'Unable to push the job to Sidekiq' if ::Sidekiq::Client.push(@options.merge('args' => [payload])).nil?
13
+ return unless ::Sidekiq::Client.push(@options.merge('args' => [payload])).nil?
14
+
15
+ raise(StandardError, 'Unable to push the job to Sidekiq')
14
16
  end
15
17
 
16
18
  include ::Sidekiq::Worker
@@ -7,8 +7,7 @@ module Rollbar
7
7
  include ::SuckerPunch::Job
8
8
 
9
9
  class << self
10
- attr_accessor :perform_proc
11
- attr_accessor :ready
10
+ attr_accessor :perform_proc, :ready
12
11
  end
13
12
 
14
13
  self.ready = false
@@ -62,11 +62,12 @@ module Rollbar
62
62
  reaper.join
63
63
  end
64
64
  rescue Timeout::Error
65
- raise TimeoutError, "unable to reap all threads within #{EXIT_TIMEOUT} seconds"
65
+ raise TimeoutError,
66
+ "unable to reap all threads within #{EXIT_TIMEOUT} seconds"
66
67
  end
67
68
  end
68
69
  end
69
- end # class << self
70
+ end
70
71
 
71
72
  def priority
72
73
  self.class.options[:priority] || DEFAULT_PRIORITY
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Rollbar
2
4
  # Deploy Tracking API wrapper module
3
5
  module Deploy
@@ -28,9 +30,7 @@ module Rollbar
28
30
  return {} unless access_token && !access_token.empty?
29
31
 
30
32
  uri = ::URI.parse(
31
- ::Rollbar::Deploy::ENDPOINT +
32
- deploy_id.to_s +
33
- '?access_token=' + access_token
33
+ "#{::Rollbar::Deploy::ENDPOINT}#{deploy_id}?access_token=#{access_token}"
34
34
  )
35
35
 
36
36
  request = ::Net::HTTP::Patch.new(uri.request_uri)
@@ -72,17 +72,18 @@ module Rollbar
72
72
 
73
73
  def request_result(uri, request)
74
74
  {
75
- :request_info => uri.inspect + ': ' + request.body,
75
+ :request_info => "#{uri.inspect}: #{request.body}",
76
76
  :request => request
77
77
  }
78
78
  end
79
79
 
80
80
  def response_result(response)
81
+ code = response.code
82
+ message = response.message
83
+ body = response.body.delete("\n")
81
84
  {
82
85
  :response => response,
83
- :response_info => response.code + '; ' +
84
- response.message + '; ' +
85
- response.body.delete("\n")
86
+ :response_info => "#{code}; #{message}; #{body}"
86
87
  }.merge(::JSON.parse(response.body, :symbolize_names => true))
87
88
  end
88
89
  end
@@ -1,8 +1,10 @@
1
1
  module Rollbar
2
2
  module Encoding
3
3
  class Encoder
4
- ALL_ENCODINGS = [::Encoding::UTF_8, ::Encoding::ISO_8859_1, ::Encoding::ASCII_8BIT, ::Encoding::US_ASCII].freeze
5
- ASCII_ENCODINGS = [::Encoding::US_ASCII, ::Encoding::ASCII_8BIT, ::Encoding::ISO_8859_1].freeze
4
+ ALL_ENCODINGS = [::Encoding::UTF_8, ::Encoding::ISO_8859_1, ::Encoding::ASCII_8BIT,
5
+ ::Encoding::US_ASCII].freeze
6
+ ASCII_ENCODINGS = [::Encoding::US_ASCII, ::Encoding::ASCII_8BIT,
7
+ ::Encoding::ISO_8859_1].freeze
6
8
  UTF8 = 'UTF-8'.freeze
7
9
  BINARY = 'binary'.freeze
8
10
 
@@ -30,6 +32,9 @@ module Rollbar
30
32
  end
31
33
 
32
34
  object.is_a?(Symbol) ? encoded_value.to_sym : encoded_value
35
+ rescue StandardError => e
36
+ # If encoding fails for any reason, replace the string with a diagnostic error.
37
+ "error encoding string: #{e.class}: #{e.message}"
33
38
  end
34
39
 
35
40
  private
@@ -37,7 +42,9 @@ module Rollbar
37
42
  def force_encoding(value)
38
43
  return value if value.frozen?
39
44
 
40
- value.force_encoding(detect_encoding(value)) if value.encoding == ::Encoding::UTF_8
45
+ if value.encoding == ::Encoding::UTF_8
46
+ value.force_encoding(detect_encoding(value))
47
+ end
41
48
 
42
49
  value
43
50
  end
@@ -7,16 +7,23 @@ module Rollbar
7
7
 
8
8
  exception_data = exception_data(exception)
9
9
 
10
- if exception_data.is_a?(Hash)
10
+ case exception_data
11
+ when Hash
11
12
  env['rollbar.exception_uuid'] = exception_data[:uuid]
12
- Rollbar.log_debug "[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
13
- elsif exception_data == 'disabled'
14
- Rollbar.log_debug '[Rollbar] Exception not reported because Rollbar is disabled'
15
- elsif exception_data == 'ignored'
13
+ Rollbar.log_debug(
14
+ "[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
15
+ )
16
+ when 'disabled'
17
+ Rollbar.log_debug(
18
+ '[Rollbar] Exception not reported because Rollbar is disabled'
19
+ )
20
+ when 'ignored'
16
21
  Rollbar.log_debug '[Rollbar] Exception not reported because it was ignored'
17
22
  end
18
23
  rescue StandardError => e
19
- Rollbar.log_warning "[Rollbar] Exception while reporting exception to Rollbar: #{e.message}"
24
+ Rollbar.log_warning(
25
+ "[Rollbar] Exception while reporting exception to Rollbar: #{e.message}"
26
+ )
20
27
  end
21
28
 
22
29
  def capture_uncaught?
@@ -24,12 +31,14 @@ module Rollbar
24
31
  end
25
32
 
26
33
  def log_exception_message(exception)
27
- exception_message = exception.respond_to?(:message) ? exception.message : 'No Exception Message'
34
+ exception_message = exception.message if exception.respond_to?(:message)
35
+ exception_message ||= 'No Exception Message'
28
36
  Rollbar.log_debug "[Rollbar] Reporting exception: #{exception_message}"
29
37
  end
30
38
 
31
39
  def exception_data(exception)
32
- Rollbar.log(Rollbar.configuration.uncaught_exception_level, exception, :use_exception_level_filters => true)
40
+ Rollbar.log(Rollbar.configuration.uncaught_exception_level, exception,
41
+ :use_exception_level_filters => true)
33
42
  end
34
43
  end
35
44
  end
@@ -3,11 +3,7 @@ require 'rollbar/item/frame'
3
3
  module Rollbar
4
4
  class Item
5
5
  class Backtrace
6
- attr_reader :exception
7
- attr_reader :message
8
- attr_reader :extra
9
- attr_reader :configuration
10
- attr_reader :files
6
+ attr_reader :exception, :message, :extra, :configuration, :files
11
7
 
12
8
  private :files
13
9
 
@@ -54,8 +50,11 @@ module Rollbar
54
50
 
55
51
  current_exception = exception
56
52
 
57
- while current_exception.respond_to?(:cause) && (cause = current_exception.cause) && cause.is_a?(Exception) && !visited.include?(cause)
58
- traces.unshift(trace_data(cause))
53
+ while current_exception.respond_to?(:cause) &&
54
+ (cause = current_exception.cause) &&
55
+ cause.is_a?(Exception) &&
56
+ !visited.include?(cause)
57
+ traces << trace_data(cause)
59
58
  visited << cause
60
59
  current_exception = cause
61
60
  end
@@ -100,7 +99,9 @@ module Rollbar
100
99
  # are those from the user's Rollbar.error line until this method. We want
101
100
  # to remove those lines.
102
101
  def exception_backtrace(current_exception)
103
- return current_exception.backtrace if current_exception.backtrace.respond_to?(:map)
102
+ if current_exception.backtrace.respond_to?(:map)
103
+ return current_exception.backtrace
104
+ end
104
105
  return [] unless configuration.populate_empty_backtraces
105
106
 
106
107
  caller_backtrace = caller
@@ -109,7 +110,8 @@ module Rollbar
109
110
  end
110
111
 
111
112
  def rollbar_lib_gem_dir
112
- Gem::Specification.find_by_name('rollbar').gem_dir + '/lib'
113
+ gem_dir = Gem::Specification.find_by_name('rollbar').gem_dir
114
+ "#{gem_dir}/lib"
113
115
  end
114
116
  end
115
117
  end
@@ -6,9 +6,7 @@ module Rollbar
6
6
  class Item
7
7
  # Representation of the trace data per frame in the payload
8
8
  class Frame
9
- attr_reader :backtrace
10
- attr_reader :frame
11
- attr_reader :configuration
9
+ attr_reader :backtrace, :frame, :configuration
12
10
 
13
11
  MAX_CONTEXT_LENGTH = 4
14
12
 
@@ -104,7 +102,8 @@ module Rollbar
104
102
 
105
103
  def post_data(file_lines, lineno)
106
104
  from_line = lineno
107
- number_of_lines = [from_line + MAX_CONTEXT_LENGTH, file_lines.size].min - from_line
105
+ number_of_lines = [from_line + MAX_CONTEXT_LENGTH,
106
+ file_lines.size].min - from_line
108
107
 
109
108
  file_lines[from_line, number_of_lines]
110
109
  end
@@ -113,7 +112,9 @@ module Rollbar
113
112
  to_line = lineno - 2
114
113
  from_line = [to_line - MAX_CONTEXT_LENGTH + 1, 0].max
115
114
 
116
- file_lines[from_line, (to_line - from_line + 1)].select { |line| line && !line.empty? }
115
+ file_lines[from_line, (to_line - from_line + 1)].select do |line|
116
+ line && !line.empty?
117
+ end
117
118
  end
118
119
  end
119
120
  end
@@ -1,4 +1,3 @@
1
- require 'rollbar/notifier'
2
1
  require 'rollbar/scrubbers/params'
3
2
  require 'rollbar/util'
4
3
 
@@ -59,7 +58,9 @@ module Rollbar
59
58
  # truncation strategy for large payloads.
60
59
  #
61
60
  def prepare_value(value)
62
- return simple_value?(value) ? value : value.inspect unless value.is_a?(Hash) || value.is_a?(Array)
61
+ unless value.is_a?(Hash) || value.is_a?(Array)
62
+ return simple_value?(value) ? value : value.inspect
63
+ end
63
64
 
64
65
  cloned_value = ::Rollbar::Util.deep_copy(value)
65
66
  ::Rollbar::Util.iterate_and_update_with_block(cloned_value) do |v|