yeller_ruby 0.4.1 → 0.5.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.
- checksums.yaml +4 -4
- data/lib/yeller/exception_formatter.rb +37 -17
- data/lib/yeller/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 987873d3cdad8bcf664a9c4970742526239d5303
|
4
|
+
data.tar.gz: b699500e4c0f6e7adbb3a651ad6298f292c1a33d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1fd2d3ab49ae81801d2ce90c94f736e57916928c2ff6cf20331fb6e8cc011c31d47fa26199e25d9dbce5c4a7ed9601a5323cdd5603a05542f0a7d97797b8848
|
7
|
+
data.tar.gz: 0e51458e66b81d0a630913b9df726bf22dd76ec2df49a5c741f84e079a5f4db47897a3bff5e7ebbc09b2da0ad430b53b60ab3111279921956b7695e68aa433d4
|
@@ -9,26 +9,35 @@ module Yeller
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.format(exception, backtrace_filter=IdentityBacktraceFilter.new, options={})
|
12
|
-
|
12
|
+
all_causes = process_causes(exception)
|
13
|
+
root = all_causes.fetch(0, exception)
|
14
|
+
causes = all_causes.drop(1)
|
15
|
+
new(root, causes || [], backtrace_filter, options).to_hash
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.process_causes(exception)
|
19
|
+
unwrap_causes(exception, [])
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.unwrap_causes(exception, causes)
|
23
|
+
causes << exception
|
24
|
+
if exception.respond_to?(:cause) && exception.cause
|
25
|
+
unwrap_causes(exception.cause, causes)
|
26
|
+
else
|
27
|
+
causes.reverse
|
28
|
+
end
|
13
29
|
end
|
14
30
|
|
15
31
|
attr_reader :type, :options, :backtrace_filter
|
16
32
|
|
17
|
-
def initialize(e, backtrace_filter, options)
|
18
|
-
exception =
|
33
|
+
def initialize(e, causes, backtrace_filter, options)
|
34
|
+
exception = e
|
19
35
|
@type = exception.class.name
|
20
36
|
@message = exception.message
|
21
37
|
@backtrace = exception.backtrace
|
22
|
-
@
|
38
|
+
@causes = causes
|
23
39
|
@backtrace_filter = backtrace_filter
|
24
|
-
|
25
|
-
|
26
|
-
def unwrap_nested_exception(e)
|
27
|
-
if e.respond_to?(:cause) && e.cause
|
28
|
-
e.cause
|
29
|
-
else
|
30
|
-
e
|
31
|
-
end
|
40
|
+
@options = options
|
32
41
|
end
|
33
42
|
|
34
43
|
def message
|
@@ -36,22 +45,33 @@ module Yeller
|
|
36
45
|
@message == type ? nil : @message
|
37
46
|
end
|
38
47
|
|
39
|
-
def formatted_backtrace
|
40
|
-
return [] unless
|
48
|
+
def formatted_backtrace(backtrace)
|
49
|
+
return [] unless backtrace
|
41
50
|
|
42
|
-
original_trace =
|
51
|
+
original_trace = backtrace.map do |line|
|
43
52
|
_, file, number, method = line.match(BACKTRACE_FORMAT).to_a
|
44
53
|
[file, number, method]
|
45
54
|
end
|
46
55
|
backtrace_filter.filter(original_trace)
|
47
56
|
end
|
48
57
|
|
58
|
+
def causes
|
59
|
+
@causes.map do |cause|
|
60
|
+
{
|
61
|
+
:type => cause.class.name,
|
62
|
+
:message => cause.message,
|
63
|
+
:stacktrace => formatted_backtrace(cause.backtrace),
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
49
68
|
def to_hash
|
50
69
|
result = {
|
51
70
|
:message => message,
|
52
|
-
:stacktrace => formatted_backtrace,
|
71
|
+
:stacktrace => formatted_backtrace(@backtrace),
|
53
72
|
:type => type,
|
54
|
-
:"custom-data" => options.fetch(:custom_data, {})
|
73
|
+
:"custom-data" => options.fetch(:custom_data, {}),
|
74
|
+
:causes => causes,
|
55
75
|
}
|
56
76
|
result[:url] = options[:url] if options.key?(:url)
|
57
77
|
result[:location] = options[:location] if options.key?(:location)
|
data/lib/yeller/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yeller_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Crayford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|