airbrake-ruby 2.5.0.rc.3 → 2.5.0.rc.4
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.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby/backtrace.rb +3 -2
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/backtrace_spec.rb +29 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 723a69b477b7427cce788252556a5787cdfb0e3f
|
4
|
+
data.tar.gz: ebcde2029d361259bc27fdbd1573b5617f550352
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c81879d7a36df9412c75292314117f0ae46b555a6fe995e52a0d4d661b4ab8d812d38a5e8f658fe512b07762171a8e64c3019b1838e9b1a19e6696e56c4d9700
|
7
|
+
data.tar.gz: 81e6a8137d913c6f68007647b22178f3f1001eaffb325004ac8b1eefbb8b1e1fca47d3326c8a1498805fa9a212a0d4086f32389de9eaa8c177283743dad3e56b
|
@@ -182,6 +182,7 @@ module Airbrake
|
|
182
182
|
|
183
183
|
def parse_backtrace(config, exception)
|
184
184
|
regexp = best_regexp_for(exception)
|
185
|
+
root_directory = config.root_directory.to_s
|
185
186
|
|
186
187
|
exception.backtrace.map.with_index do |stackframe, i|
|
187
188
|
unless (match = match_frame(regexp, stackframe))
|
@@ -195,8 +196,8 @@ module Airbrake
|
|
195
196
|
frame = stack_frame(match)
|
196
197
|
next(frame) unless config.code_hunks
|
197
198
|
|
198
|
-
if
|
199
|
-
if frame[:file].start_with?(
|
199
|
+
if !root_directory.empty?
|
200
|
+
if frame[:file].start_with?(root_directory)
|
200
201
|
populate_code(config, frame)
|
201
202
|
end
|
202
203
|
elsif i < CODE_FRAME_LIMIT
|
data/spec/backtrace_spec.rb
CHANGED
@@ -335,6 +335,35 @@ RSpec.describe Airbrake::Backtrace do
|
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
|
+
context "and when root_directory is a Pathname" do
|
339
|
+
before { config.root_directory = Pathname.new(project_root_path('')) }
|
340
|
+
|
341
|
+
let(:parsed_backtrace) do
|
342
|
+
[
|
343
|
+
{
|
344
|
+
file: project_root_path('code.rb'),
|
345
|
+
line: 94,
|
346
|
+
function: 'to_json',
|
347
|
+
code: {
|
348
|
+
92 => ' loop do',
|
349
|
+
93 => ' begin',
|
350
|
+
94 => ' json = @payload.to_json',
|
351
|
+
95 => ' rescue *JSON_EXCEPTIONS => ex',
|
352
|
+
# rubocop:disable Metrics/LineLength,Lint/InterpolationCheck
|
353
|
+
96 => ' @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
|
354
|
+
# rubocop:enable Metrics/LineLength,Lint/InterpolationCheck
|
355
|
+
}
|
356
|
+
}
|
357
|
+
]
|
358
|
+
end
|
359
|
+
|
360
|
+
it "attaches code to those frames files of which match root_directory" do
|
361
|
+
ex = RuntimeError.new
|
362
|
+
ex.set_backtrace([project_root_path('code.rb') + ":94:in `to_json'"])
|
363
|
+
expect(described_class.parse(config, ex)).to eq(parsed_backtrace)
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
338
367
|
context "and when root_directory isn't configured" do
|
339
368
|
before do
|
340
369
|
config.root_directory = nil
|