failbot 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/failbot.rb +10 -0
- data/lib/failbot/backtrace.rb +33 -5
- data/lib/failbot/exception_format/structured.rb +1 -0
- data/lib/failbot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e182bf0325cad972095bfc874140de2c28b0b771070719e7aff54fb02d8fae
|
4
|
+
data.tar.gz: 8da6d5c26fcfe301e0df2edf096e2afa0e19f40e5941ae5b03e084d8435cfab0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04c21e6c698b040686e522ebe442c04b03a31c4875e904395f4e312e07cc1741e31b59f7eca22dd5475fd32a8a867c0537306f5fbf36ef44870b5337f62ef31e
|
7
|
+
data.tar.gz: e13a7e8a016abddc60e5f071cc4b46d73f3f4e42e575bd123999d68dafdfcd7b42ec1ce2e52dfa0c4a8032b5acfbfaaaf93d6dd43efaf201ab1ad30ad085bd78
|
data/lib/failbot.rb
CHANGED
@@ -46,6 +46,16 @@ module Failbot
|
|
46
46
|
# prevent recursive calls to Failbot.report!
|
47
47
|
attr_accessor :already_reporting
|
48
48
|
|
49
|
+
# Root directory of the project's source. Used to clean up stack traces if the exception format supports it
|
50
|
+
|
51
|
+
def source_root=(str)
|
52
|
+
@source_root = if str
|
53
|
+
File.join(str, '')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
attr_reader :source_root
|
58
|
+
|
49
59
|
# see failbot/exit_hook.rb for more on these
|
50
60
|
@failbot_loaded = true
|
51
61
|
@auto_install_hook = false
|
data/lib/failbot/backtrace.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Failbot
|
2
2
|
# A simple parser to extract structure from ruby backtraces.
|
3
|
+
#
|
4
|
+
# See https://docs.sentry.io/development/sdk-dev/event-payloads/stacktrace/ for details on what data can sent
|
3
5
|
class Backtrace
|
4
6
|
# Raised when a line fails parsing.
|
5
7
|
ParseError = Class.new(StandardError)
|
@@ -30,27 +32,53 @@ module Failbot
|
|
30
32
|
FRAME_FORMAT = /
|
31
33
|
\A
|
32
34
|
\s*
|
33
|
-
([^:]+ | <.*>): #
|
35
|
+
([^:]+ | <.*>): # abs_path
|
34
36
|
(\d+) # line_number
|
35
37
|
(?: :in \s `([^']+)')? # method
|
36
38
|
\z
|
37
39
|
/x
|
38
40
|
|
39
|
-
attr_reader :file_name, :line_number, :method
|
41
|
+
attr_reader :file_name, :line_number, :method, :abs_path
|
40
42
|
|
41
43
|
# Returns a Frame given backtrace component string or raises
|
42
44
|
# ParseError if it's malformed.
|
43
45
|
def self.parse(unparsed_line)
|
44
46
|
match = unparsed_line.match(FRAME_FORMAT)
|
45
47
|
if match
|
46
|
-
|
47
|
-
|
48
|
+
abs_path, line_number, method = match.captures
|
49
|
+
|
50
|
+
file_name = extract_file_name(abs_path)
|
51
|
+
|
52
|
+
new(abs_path, file_name, line_number, method)
|
48
53
|
else
|
49
54
|
raise ParseError, "unable to parse #{unparsed_line.inspect}"
|
50
55
|
end
|
51
56
|
end
|
52
57
|
|
53
|
-
|
58
|
+
# Older versions of ruby don't have String#delete_prefix so for them we
|
59
|
+
# fall back to a slower implementation.
|
60
|
+
if String.new.respond_to?(:delete_prefix)
|
61
|
+
def self.extract_file_name(abs_path)
|
62
|
+
if Failbot.source_root
|
63
|
+
abs_path.delete_prefix(Failbot.source_root)
|
64
|
+
else
|
65
|
+
abs_path
|
66
|
+
end
|
67
|
+
end
|
68
|
+
else
|
69
|
+
def self.extract_file_name(abs_path)
|
70
|
+
if Failbot.source_root
|
71
|
+
abs_path.gsub(/\A#{Failbot.source_root}/, "")
|
72
|
+
else
|
73
|
+
abs_path
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private_class_method :extract_file_name
|
79
|
+
|
80
|
+
def initialize(abs_path, file_name, line_number, method)
|
81
|
+
@abs_path = abs_path
|
54
82
|
@file_name = file_name
|
55
83
|
@line_number = line_number
|
56
84
|
@method = method
|
data/lib/failbot/version.rb
CHANGED