yeller_ruby 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33fe054283424e5b1d98ea57cef0f6d69d10e038
4
- data.tar.gz: 973837ba97c4adb19c4007a889ce16ea0dd94aab
3
+ metadata.gz: 987873d3cdad8bcf664a9c4970742526239d5303
4
+ data.tar.gz: b699500e4c0f6e7adbb3a651ad6298f292c1a33d
5
5
  SHA512:
6
- metadata.gz: 29976834a9299621b9759aba6256aa34da79c855bea1dd0c065adc5ec490a5931243d564ac3d26f4a8681650a701a6debd3175427ca8e27c0c0a2baa35ea1b26
7
- data.tar.gz: b09a4dd8cc48c23972a69aa4b8ab5e0b293f932122e5ba7fee6135ff840cfabc7b0a5a8c589023a9693b42b10b3420a517864bbfff2ab5ed7f51bdfef1085ebf
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
- new(exception, backtrace_filter, options).to_hash
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 = unwrap_nested_exception(e)
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
- @options = options
38
+ @causes = causes
23
39
  @backtrace_filter = backtrace_filter
24
- end
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 @backtrace
48
+ def formatted_backtrace(backtrace)
49
+ return [] unless backtrace
41
50
 
42
- original_trace = @backtrace.map do |line|
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)
@@ -1,3 +1,3 @@
1
1
  module Yeller
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
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.1
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-08 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler