rollbar 2.26.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +34 -0
  3. data/.github/workflows/ci.yml +104 -0
  4. data/.rubocop.yml +52 -36
  5. data/Gemfile +25 -29
  6. data/README.md +32 -8
  7. data/data/rollbar.snippet.js +1 -1
  8. data/docs/configuration.md +7 -0
  9. data/gemfiles/rails30.gemfile +17 -35
  10. data/gemfiles/rails31.gemfile +20 -37
  11. data/gemfiles/rails32.gemfile +13 -31
  12. data/gemfiles/rails40.gemfile +12 -32
  13. data/gemfiles/rails41.gemfile +11 -31
  14. data/gemfiles/rails42.gemfile +11 -35
  15. data/gemfiles/rails50.gemfile +14 -32
  16. data/gemfiles/rails51.gemfile +13 -31
  17. data/gemfiles/rails52.gemfile +10 -19
  18. data/gemfiles/rails60.gemfile +10 -25
  19. data/gemfiles/rails61.gemfile +52 -0
  20. data/gemfiles/rails70.gemfile +52 -0
  21. data/lib/generators/rollbar/rollbar_generator.rb +18 -14
  22. data/lib/rails/rollbar_runner.rb +8 -19
  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 +122 -88
  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 +6 -7
  32. data/lib/rollbar/encoding/encoder.rb +7 -3
  33. data/lib/rollbar/encoding.rb +2 -7
  34. data/lib/rollbar/exception_reporter.rb +17 -8
  35. data/lib/rollbar/item/backtrace.rb +10 -8
  36. data/lib/rollbar/item/frame.rb +6 -5
  37. data/lib/rollbar/item/locals.rb +5 -2
  38. data/lib/rollbar/item.rb +60 -38
  39. data/lib/rollbar/json.rb +1 -1
  40. data/lib/rollbar/language_support.rb +0 -6
  41. data/lib/rollbar/lazy_store.rb +3 -7
  42. data/lib/rollbar/logger.rb +2 -0
  43. data/lib/rollbar/logger_proxy.rb +3 -1
  44. data/lib/rollbar/middleware/js/json_value.rb +15 -5
  45. data/lib/rollbar/middleware/js.rb +59 -37
  46. data/lib/rollbar/middleware/rack/builder.rb +3 -3
  47. data/lib/rollbar/middleware/rack/test_session.rb +3 -3
  48. data/lib/rollbar/middleware/rack.rb +4 -4
  49. data/lib/rollbar/middleware/rails/rollbar.rb +9 -6
  50. data/lib/rollbar/middleware/rails/show_exceptions.rb +8 -4
  51. data/lib/rollbar/notifier/trace_with_bindings.rb +13 -3
  52. data/lib/rollbar/notifier.rb +180 -136
  53. data/lib/rollbar/plugin.rb +8 -8
  54. data/lib/rollbar/plugins/active_job.rb +15 -2
  55. data/lib/rollbar/plugins/delayed_job/plugin.rb +14 -3
  56. data/lib/rollbar/plugins/goalie.rb +27 -16
  57. data/lib/rollbar/plugins/rails/controller_methods.rb +18 -14
  58. data/lib/rollbar/plugins/rails/railtie30.rb +2 -1
  59. data/lib/rollbar/plugins/rails/railtie32.rb +2 -1
  60. data/lib/rollbar/plugins/rails/railtie_mixin.rb +2 -2
  61. data/lib/rollbar/plugins/rails.rb +5 -2
  62. data/lib/rollbar/plugins/rake.rb +2 -1
  63. data/lib/rollbar/plugins/sidekiq/plugin.rb +39 -21
  64. data/lib/rollbar/plugins/sidekiq.rb +1 -1
  65. data/lib/rollbar/plugins/thread.rb +8 -7
  66. data/lib/rollbar/plugins/validations.rb +3 -1
  67. data/lib/rollbar/rake_tasks.rb +1 -2
  68. data/lib/rollbar/request_data_extractor.rb +48 -19
  69. data/lib/rollbar/rollbar_test.rb +9 -118
  70. data/lib/rollbar/scrubbers/params.rb +13 -7
  71. data/lib/rollbar/scrubbers/url.rb +56 -17
  72. data/lib/rollbar/scrubbers.rb +1 -1
  73. data/lib/rollbar/truncation/remove_any_key_strategy.rb +4 -1
  74. data/lib/rollbar/truncation/remove_extra_strategy.rb +3 -1
  75. data/lib/rollbar/util/hash.rb +14 -7
  76. data/lib/rollbar/util/ip_anonymizer.rb +1 -1
  77. data/lib/rollbar/util.rb +19 -13
  78. data/lib/rollbar/version.rb +1 -1
  79. data/lib/rollbar.rb +12 -7
  80. data/lib/tasks/benchmark.rake +2 -1
  81. data/rollbar.gemspec +5 -3
  82. metadata +17 -12
  83. data/.travis.yml +0 -284
  84. data/lib/rollbar/encoding/legacy_encoder.rb +0 -20
  85. /data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +0 -0
@@ -4,79 +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 :framework
28
- attr_accessor :ignored_person_ids
29
- attr_accessor :host
30
- attr_accessor :locals
31
- attr_writer :logger
32
- attr_accessor :payload_options
33
- attr_accessor :person_method
34
- attr_accessor :person_id_method
35
- attr_accessor :person_username_method
36
- attr_accessor :person_email_method
37
- attr_accessor :populate_empty_backtraces
38
- attr_accessor :report_dj_data
39
- attr_accessor :open_timeout
40
- attr_accessor :request_timeout
41
- attr_accessor :net_retries
42
- attr_accessor :root
43
- attr_accessor :js_options
44
- attr_accessor :js_enabled
45
- attr_accessor :safely
46
- attr_accessor :scrub_fields
47
- attr_accessor :scrub_user
48
- attr_accessor :scrub_password
49
- attr_accessor :scrub_whitelist
50
- attr_accessor :collect_user_ip
51
- attr_accessor :anonymize_user_ip
52
- attr_accessor :user_ip_obfuscator_secret
53
- attr_accessor :randomize_scrub_length
54
- attr_accessor :uncaught_exception_level
55
- attr_accessor :scrub_headers
56
- attr_accessor :sidekiq_threshold
57
- attr_reader :transform
58
- attr_accessor :verify_ssl_peer
59
- attr_accessor :use_async
60
- attr_accessor :async_json_payload
61
- attr_reader :use_eventmachine
62
- attr_accessor :web_base
63
- attr_reader :send_extra_frame_data
64
- attr_accessor :use_exception_level_filters_default
65
- attr_accessor :proxy
66
- attr_accessor :raise_on_error
67
- attr_accessor :transmit
68
- attr_accessor :log_payload
69
- attr_accessor :backtrace_cleaner
70
-
71
- attr_accessor :write_to_file
72
- attr_accessor :filepath
73
- attr_accessor :files_with_pid_name_enabled
74
- attr_accessor :files_processed_enabled
75
- attr_accessor :files_processed_duration # seconds
76
- attr_accessor :files_processed_size # bytes
77
-
78
- attr_reader :project_gem_paths
79
- 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
80
83
 
81
84
  alias safely? safely
82
85
 
@@ -84,12 +87,14 @@ module Rollbar
84
87
  DEFAULT_WEB_BASE = 'https://rollbar.com'.freeze
85
88
 
86
89
  def initialize
90
+ @access_token = nil
87
91
  @async_handler = nil
88
92
  @before_process = []
93
+ @branch = nil
89
94
  @capture_uncaught = nil
90
95
  @code_version = nil
91
96
  @custom_data_method = nil
92
- @default_logger = lambda { ::Logger.new(STDERR) }
97
+ @default_logger = lambda { ::Logger.new($stderr) }
93
98
  @logger_level = :info
94
99
  @delayed_job_enabled = true
95
100
  @disable_monkey_patch = false
@@ -97,6 +102,7 @@ module Rollbar
97
102
  @disable_rack_monkey_patch = false
98
103
  @enable_error_context = true
99
104
  @dj_threshold = 0
105
+ @async_skip_report_handler = nil
100
106
  @enabled = nil # set to true when configure is called
101
107
  @endpoint = DEFAULT_ENDPOINT
102
108
  @environment = nil
@@ -107,7 +113,13 @@ module Rollbar
107
113
  }
108
114
  @failover_handlers = []
109
115
  @framework = 'Plain'
116
+ @ignore_internal_errors = [
117
+ 'Net::ReadTimeout',
118
+ 'Net::OpenTimeout',
119
+ 'SocketError'
120
+ ]
110
121
  @ignored_person_ids = []
122
+ @host = nil
111
123
  @payload_options = {}
112
124
  @person_method = 'current_user'
113
125
  @person_id_method = 'id'
@@ -119,6 +131,7 @@ module Rollbar
119
131
  @open_timeout = 3
120
132
  @request_timeout = 3
121
133
  @net_retries = 3
134
+ @root = nil
122
135
  @js_enabled = false
123
136
  @js_options = {}
124
137
  @locals = {}
@@ -132,6 +145,7 @@ module Rollbar
132
145
  @uncaught_exception_level = 'error'
133
146
  @scrub_headers = ['Authorization']
134
147
  @sidekiq_threshold = 0
148
+ @sidekiq_use_scoped_block = false
135
149
  @safely = false
136
150
  @transform = []
137
151
  @use_async = false
@@ -148,6 +162,8 @@ module Rollbar
148
162
  @log_payload = false
149
163
  @collect_user_ip = true
150
164
  @anonymize_user_ip = false
165
+ @user_ip_obfuscator_secret = nil
166
+ @user_ip_rack_env_key = nil
151
167
  @backtrace_cleaner = nil
152
168
  @hooks = {
153
169
  :on_error_response => nil, # params: response
@@ -155,10 +171,12 @@ module Rollbar
155
171
  }
156
172
 
157
173
  @write_to_file = false
174
+ @filepath = nil
158
175
  @files_with_pid_name_enabled = false
159
176
  @files_processed_enabled = false
160
177
  @files_processed_duration = 60
161
178
  @files_processed_size = 5 * 1000 * 1000
179
+ @use_payload_access_token = false
162
180
 
163
181
  @configured_options = ConfiguredOptions.new(self)
164
182
  end
@@ -202,7 +220,8 @@ module Rollbar
202
220
  def use_active_job(options = {})
203
221
  require 'rollbar/delay/active_job'
204
222
 
205
- 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)
206
225
 
207
226
  @use_async = true
208
227
  @async_handler = Rollbar::Delay::ActiveJob
@@ -242,8 +261,13 @@ module Rollbar
242
261
  end
243
262
 
244
263
  def use_sidekiq=(value)
245
- deprecation_message = '#use_sidekiq=(value) has been deprecated in favor of #use_sidekiq(options = {}). Please update your rollbar configuration.'
246
- 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
247
271
 
248
272
  value.is_a?(Hash) ? use_sidekiq(value) : use_sidekiq
249
273
  end
@@ -262,8 +286,13 @@ module Rollbar
262
286
  end
263
287
 
264
288
  def use_sucker_punch=(_value)
265
- deprecation_message = '#use_sucker_punch=(value) has been deprecated in favor of #use_sucker_punch. Please update your rollbar configuration.'
266
- 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
267
296
 
268
297
  use_sucker_punch
269
298
  end
@@ -294,7 +323,9 @@ module Rollbar
294
323
 
295
324
  def send_extra_frame_data=(value)
296
325
  unless SEND_EXTRA_FRAME_DATA_OPTIONS.include?(value)
297
- 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 :all is expected"
328
+ )
298
329
 
299
330
  return
300
331
  end
@@ -320,14 +351,14 @@ module Rollbar
320
351
  end
321
352
 
322
353
  def hook(symbol, &block)
323
- if @hooks.key?(symbol)
324
- if block_given?
325
- @hooks[symbol] = block
326
- else
327
- @hooks[symbol]
328
- 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
329
360
  else
330
- raise StandardError, 'Hook :' + symbol.to_s + ' is not supported by Rollbar SDK.'
361
+ @hooks[symbol]
331
362
  end
332
363
  end
333
364
 
@@ -348,7 +379,10 @@ module Rollbar
348
379
  return super unless configuration.respond_to?(method)
349
380
 
350
381
  method_string = method.to_s
351
- 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
352
386
 
353
387
  configuration.send(method, *args, &block)
354
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
@@ -30,9 +30,7 @@ module Rollbar
30
30
  return {} unless access_token && !access_token.empty?
31
31
 
32
32
  uri = ::URI.parse(
33
- ::Rollbar::Deploy::ENDPOINT +
34
- deploy_id.to_s +
35
- '?access_token=' + access_token
33
+ "#{::Rollbar::Deploy::ENDPOINT}#{deploy_id}?access_token=#{access_token}"
36
34
  )
37
35
 
38
36
  request = ::Net::HTTP::Patch.new(uri.request_uri)
@@ -74,17 +72,18 @@ module Rollbar
74
72
 
75
73
  def request_result(uri, request)
76
74
  {
77
- :request_info => uri.inspect + ': ' + request.body,
75
+ :request_info => "#{uri.inspect}: #{request.body}",
78
76
  :request => request
79
77
  }
80
78
  end
81
79
 
82
80
  def response_result(response)
81
+ code = response.code
82
+ message = response.message
83
+ body = response.body.delete("\n")
83
84
  {
84
85
  :response => response,
85
- :response_info => response.code + '; ' +
86
- response.message + '; ' +
87
- response.body.delete("\n")
86
+ :response_info => "#{code}; #{message}; #{body}"
88
87
  }.merge(::JSON.parse(response.body, :symbolize_names => true))
89
88
  end
90
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
 
@@ -40,7 +42,9 @@ module Rollbar
40
42
  def force_encoding(value)
41
43
  return value if value.frozen?
42
44
 
43
- 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
44
48
 
45
49
  value
46
50
  end
@@ -5,13 +5,8 @@ module Rollbar
5
5
  end
6
6
 
7
7
  def self.setup
8
- if String.instance_methods.include?(:encode)
9
- require 'rollbar/encoding/encoder'
10
- self.encoding_class = Rollbar::Encoding::Encoder
11
- else
12
- require 'rollbar/encoding/legacy_encoder'
13
- self.encoding_class = Rollbar::Encoding::LegacyEncoder
14
- end
8
+ require 'rollbar/encoding/encoder'
9
+ self.encoding_class = Rollbar::Encoding::Encoder
15
10
  end
16
11
 
17
12
  def self.encode(object)
@@ -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,7 +50,10 @@ 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)
53
+ while current_exception.respond_to?(:cause) &&
54
+ (cause = current_exception.cause) &&
55
+ cause.is_a?(Exception) &&
56
+ !visited.include?(cause)
58
57
  traces << trace_data(cause)
59
58
  visited << cause
60
59
  current_exception = cause
@@ -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
 
@@ -33,6 +32,8 @@ module Rollbar
33
32
  end
34
33
 
35
34
  def locals_for(frame)
35
+ return {} unless frame
36
+
36
37
  {}.tap do |hash|
37
38
  frame.local_variables.map do |var|
38
39
  hash[var] = prepare_value(frame.local_variable_get(var))
@@ -59,7 +60,9 @@ module Rollbar
59
60
  # truncation strategy for large payloads.
60
61
  #
61
62
  def prepare_value(value)
62
- return simple_value?(value) ? value : value.inspect unless value.is_a?(Hash) || value.is_a?(Array)
63
+ unless value.is_a?(Hash) || value.is_a?(Array)
64
+ return simple_value?(value) ? value : value.inspect
65
+ end
63
66
 
64
67
  cloned_value = ::Rollbar::Util.deep_copy(value)
65
68
  ::Rollbar::Util.iterate_and_update_with_block(cloned_value) do |v|