paul_bunyan 1.2.3 → 1.3.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: 56f9035eeff5fe301e6f14ee5ed3df1c07d93cf2
4
- data.tar.gz: 1740d2847bcc3542ef0ff9cd37ee3da20dd8b760
3
+ metadata.gz: aaba25e126d5666479137139dc258a03599caac3
4
+ data.tar.gz: 188f3801cbb78f8fd610db03867ae509f5f22953
5
5
  SHA512:
6
- metadata.gz: 80e44079fd27a47a525d93beef40fd4044fddee54997e13beccaeffb9f77fc460e7ab48e4c0306a3204adc5d83557356739a66dfdca13adb04bdaa9bfb8f8226
7
- data.tar.gz: 42cd5cc00964a7cf513ba0442b672ab938e71972772a48c2d5c5dd4940d974173998afa5b3158eaddb8be74f2ffbcbc1b04985079633aac1850d45e1a3d599c9
6
+ metadata.gz: 6318d4c839fb4729bc8f179b6b32c00bdd0e42c98d995ea2b8cd23442a89e2c0146f344e3272deba47c89f9fe3cb7f666b3c5c38d7cbb1ebeb4f668429527793
7
+ data.tar.gz: 42ff870a5bf157e5c7ff1bca6cf5bcd96e92fce8b44ef0c6be730274a81561315096797ec590fed0316144c8a81896133c950d695a6900364791498c5ac99068
@@ -70,17 +70,29 @@ module PaulBunyan
70
70
  end
71
71
 
72
72
  def format_exception(exception)
73
- # TODO: capture the exception cause if it is present and handle the case where
74
- # cause isn't actually an exception (such as Parslet::ParseFailed#cause)
75
73
  {
76
- "exception.class" => exception.class.to_s,
77
- "exception.backtrace" => exception.backtrace,
78
- "exception.message" => exception.message,
79
- }
74
+ 'exception.class' => exception.class.to_s,
75
+ 'exception.backtrace' => exception.backtrace,
76
+ 'exception.message' => exception.message
77
+ }.tap do |exception_hash|
78
+ exception_hash['exception.cause'] = format_exception_cause(exception.cause) if exception.cause
79
+ end
80
+ end
81
+
82
+ def format_exception_cause(cause)
83
+ return format_exception(cause) if cause.is_a?(Exception)
84
+
85
+ if cause.respond_to?(:to_str)
86
+ cause.to_str
87
+ elsif cause.respond_to?(:to_s)
88
+ cause.to_s
89
+ else
90
+ cause.inspect
91
+ end
80
92
  end
81
93
 
82
94
  def format_string(message)
83
- { "message" => PaulBunyan.strip_ansi(message) }
95
+ { 'message' => PaulBunyan.strip_ansi(message) }
84
96
  end
85
97
 
86
98
  def format_generic_object(object)
@@ -1,3 +1,3 @@
1
1
  module PaulBunyan
2
- VERSION = '1.2.3'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -92,8 +92,19 @@ module PaulBunyan
92
92
 
93
93
  context "when supplied an exception object" do
94
94
  let(:exception) {
95
- begin raise StandardError, "This is my exception...."
96
- rescue; exception = $!; end
95
+ begin
96
+ begin
97
+ begin
98
+ raise 'Inner-most exception'
99
+ rescue
100
+ raise 'Inner exception'
101
+ end
102
+ rescue
103
+ raise StandardError, 'This is my exception....'
104
+ end
105
+ rescue
106
+ exception = $!
107
+ end
97
108
  exception
98
109
  }
99
110
  let(:output) { formatter.call('', time, '', exception) }
@@ -110,6 +121,22 @@ module PaulBunyan
110
121
  it "must include the exception's backtrace" do
111
122
  expect(parsed_output['exception.backtrace']).to eq exception.backtrace
112
123
  end
124
+
125
+ it "must include the exception's cause" do
126
+ expect(parsed_output['exception.cause']).to include(
127
+ 'exception.class' => 'RuntimeError',
128
+ 'exception.message' => 'Inner exception',
129
+ 'exception.backtrace' => exception.cause.backtrace
130
+ )
131
+ end
132
+
133
+ it "must include the exception's cause's cause" do
134
+ expect(parsed_output['exception.cause']['exception.cause']).to include(
135
+ 'exception.class' => 'RuntimeError',
136
+ 'exception.message' => 'Inner-most exception',
137
+ 'exception.backtrace' => exception.cause.cause.backtrace
138
+ )
139
+ end
113
140
  end
114
141
  end
115
142
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paul_bunyan
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duane Johnson
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-08-19 00:00:00.000000000 Z
14
+ date: 2016-09-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: request_store