failbot 2.5.1 → 2.5.2
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/failbot.rb +5 -0
- data/lib/failbot/exception_format/haystack.rb +1 -7
- data/lib/failbot/exception_format/structured.rb +36 -7
- 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: e17fb2d80a08382f07201582e708558ab9288c33c085950136d42c38ac9e47ff
|
4
|
+
data.tar.gz: 664d9e980cb2901a1487518435a8c15bcd1e7fbce8d72eb16298e43db50d531c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5228d0b4914759a86d5605b8573f4c55de41716b2f9fa1248c6df87c169dacff3653a46da0ad4287866ecdb8a60aac5b0ed762202c0aaff89444e3b7cbbd75da
|
7
|
+
data.tar.gz: 332e27bc52d28068b62b6eda1fe30925401788ab3225f68d0a09573e07182f2caa6e7437edf6627cd94cba9fa0be04c44fd6a873e594428ea8bf78a22e2707fa
|
data/lib/failbot.rb
CHANGED
@@ -66,6 +66,11 @@ module Failbot
|
|
66
66
|
|
67
67
|
EXCEPTION_DETAIL = 'exception_detail'
|
68
68
|
|
69
|
+
# We'll include this many nested Exception#cause objects in the needle
|
70
|
+
# context. We limit the number of objects to prevent excessive recursion and
|
71
|
+
# large needle contexts.
|
72
|
+
MAXIMUM_CAUSE_DEPTH = 2
|
73
|
+
|
69
74
|
# Enumerates the available exception formats this gem supports. The original
|
70
75
|
# format and the default is :haystack and the newer format is :structured
|
71
76
|
EXCEPTION_FORMATS = {
|
@@ -30,11 +30,6 @@ module Failbot
|
|
30
30
|
hash["class"]
|
31
31
|
end
|
32
32
|
|
33
|
-
# We'll include this many nested Exception#cause objects in the needle
|
34
|
-
# context. We limit the number of objects to prevent excessive recursion and
|
35
|
-
# large needle contexts.
|
36
|
-
MAXIMUM_CAUSE_DEPTH = 2
|
37
|
-
|
38
33
|
# Pretty-print Exception#cause (and nested causes) for inclusion in needle
|
39
34
|
# context
|
40
35
|
#
|
@@ -59,7 +54,7 @@ module Failbot
|
|
59
54
|
|
60
55
|
result = causes.join("\n\nCAUSED BY:\n\n")
|
61
56
|
|
62
|
-
if current.
|
57
|
+
if current.cause
|
63
58
|
result << "\n\nFurther #cause backtraces were omitted\n"
|
64
59
|
end
|
65
60
|
|
@@ -72,7 +67,6 @@ module Failbot
|
|
72
67
|
#
|
73
68
|
# Returns a String.
|
74
69
|
def self.pretty_print_one_cause(e)
|
75
|
-
return unless e.respond_to?(:cause)
|
76
70
|
cause = e.cause
|
77
71
|
return unless cause
|
78
72
|
|
@@ -22,18 +22,47 @@ module Failbot
|
|
22
22
|
EMPTY_ARRAY
|
23
23
|
end
|
24
24
|
{
|
25
|
-
"exception_detail" =>
|
26
|
-
{ # hashes generated from subsequent calls to Exception#cause.
|
27
|
-
"type" => class_name,
|
28
|
-
"value" => message,
|
29
|
-
"stacktrace" => stacktrace
|
30
|
-
}
|
31
|
-
],
|
25
|
+
"exception_detail" => exception_details(e),
|
32
26
|
"ruby" => RUBY_DESCRIPTION,
|
33
27
|
"created_at" => Time.now.utc.iso8601(6)
|
34
28
|
}
|
35
29
|
end
|
36
30
|
|
31
|
+
FURTHER_CAUSES_WERE_OMITTED = {
|
32
|
+
"type" => "Notice",
|
33
|
+
"value" => "further Exception#cause values were omitted",
|
34
|
+
"stacktrace" => EMPTY_ARRAY
|
35
|
+
}.freeze
|
36
|
+
|
37
|
+
def self.exception_details(e)
|
38
|
+
result = []
|
39
|
+
depth = 0
|
40
|
+
|
41
|
+
loop do
|
42
|
+
message = e.message.to_s
|
43
|
+
class_name = e.class.to_s
|
44
|
+
stacktrace = begin
|
45
|
+
Failbot.backtrace_parser.call(e)
|
46
|
+
rescue => ex
|
47
|
+
message += "\nUnable to parse backtrace (#{ex.inspect})\nDon't put non-backtrace text in Exception#backtrace please!\nSo-called backtrace follows:\n#{e.backtrace.join("\n")}"
|
48
|
+
class_name += " (backtrace failed to parse)"
|
49
|
+
EMPTY_ARRAY
|
50
|
+
end
|
51
|
+
result.unshift({
|
52
|
+
"type" => class_name,
|
53
|
+
"value" => message,
|
54
|
+
"stacktrace" => stacktrace
|
55
|
+
})
|
56
|
+
depth += 1
|
57
|
+
break unless (e=e.cause)
|
58
|
+
if depth > MAXIMUM_CAUSE_DEPTH
|
59
|
+
result.unshift(FURTHER_CAUSES_WERE_OMITTED)
|
60
|
+
break
|
61
|
+
end
|
62
|
+
end
|
63
|
+
result
|
64
|
+
end
|
65
|
+
|
37
66
|
# given a hash generated by this class, return the exception message.
|
38
67
|
def self.exception_message_from_hash(hash)
|
39
68
|
hash.dig("exception_detail", 0, "value")
|
data/lib/failbot/version.rb
CHANGED