coaster 1.3.10 → 1.3.13

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
  SHA256:
3
- metadata.gz: 5b2e4ea7b170f104949852f0413f81dac320102b8045377554d8fcc8034004fd
4
- data.tar.gz: d20610716bddf3fada3e41f6b9762738ce0eaa3aca7072e5b612d93539d10d0c
3
+ metadata.gz: f0e72ea3485bb3e0fe4cf4a1ba46a8b9d15121f88451b616f7135a79b6c69513
4
+ data.tar.gz: 4ea2ff71f70966987d41ee298b06d2b98d94888faf765eb55860a3bc99d042c0
5
5
  SHA512:
6
- metadata.gz: bf519218cfcabfbe77f9cc8f6f56aafa6810048e443098fa725b0039684806413da62130545265969d43bea81f185811362c35dc1330bac688497fbd5af99287
7
- data.tar.gz: 283eb1f6a28247e902bdc986f244b249ceace63fb661c89700e0fe914b598da2acca9147334988de6d472c9327549e256ad4c34f611974dd5977e94053aedd3e
6
+ metadata.gz: 5395ecbe606496812df91dd98fc79ac6917cc0f89bf85bc3e269deeff9a1316ac562a6273e64f403f85c8fd8a865b3b6307bb9764cc6ba8704cb9908f346cb59
7
+ data.tar.gz: ae9094a1c819b49a356014c5bcc218291f4ecbb15e0670d3aaf6af88c4e52a19d2eac0b420118260927268fe01a593fb21e4f383395c0800b70b68cc0d42169b
@@ -29,6 +29,14 @@ class StandardError
29
29
  end
30
30
  end
31
31
 
32
+ def user_digests_with!(&block)
33
+ define_method(:user_digests, &block)
34
+ end
35
+
36
+ def user_digests_with_default!
37
+ define_method(:user_digests) { _user_digests }
38
+ end
39
+
32
40
  def before_logging(name, &block)
33
41
  @before_logging_blocks ||= {}
34
42
  @before_logging_blocks[name] = block
@@ -55,21 +63,25 @@ class StandardError
55
63
  @tags = {}
56
64
  @level = 'error'
57
65
  @attributes = HashWithIndifferentAccess.new
58
- @attributes.merge!(cause.attributes || {}) if cause && cause.respond_to?(:attributes)
59
66
  @tkey = nil
67
+ if cause && cause.is_a?(StandardError)
68
+ @fingerprint = cause.fingerprint.dup
69
+ @tags = cause.tags.dup
70
+ @level = cause.level
71
+ @tkey = cause.tkey
72
+ @attributes = cause.attributes.dup
73
+ end
60
74
 
61
75
  case message
62
- when Exception
63
- msg = message
64
- set_backtrace(message.backtrace)
65
76
  when StandardError
66
- @fingerprint = message.fingerprint
67
- @tags = message.tags
77
+ @fingerprint = [message.fingerprint, @fingerprint].flatten.compact.uniq
78
+ @tags = @tags.merge(message.tags || {})
68
79
  @level = message.level
69
80
  @tkey = message.tkey
70
- @attributes = message.attributes
81
+ @attributes = @attributes.merge(message.attributes || {})
82
+ msg = message
83
+ when Exception
71
84
  msg = message
72
- set_backtrace(message.backtrace)
73
85
  when Hash then
74
86
  @coaster = true # coaster 확장을 사용한 에러임을 확인할 수 있음.
75
87
  hash = message.with_indifferent_access rescue message
@@ -100,6 +112,11 @@ class StandardError
100
112
  @tags = {} unless @tags.is_a?(Hash)
101
113
  msg = "{#{cause.message}}" if msg.blank? && cause
102
114
  super(msg)
115
+ set_backtrace(msg.backtrace) if msg.is_a?(Exception)
116
+ @fingerprint << digest_message
117
+ @fingerprint << digest_backtrace
118
+ @fingerprint.compact!
119
+ self
103
120
  end
104
121
 
105
122
  def safe_message; message || '' end
@@ -111,7 +128,8 @@ class StandardError
111
128
  @digest_message ||= Digest::MD5.hexdigest(m)[0...6]
112
129
  end
113
130
  def digest_backtrace; @digest_backtrace ||= backtrace ? Digest::MD5.hexdigest(cleaned_backtrace.join("\n"))[0...8] : nil end
114
- def user_digests; @user_digests ||= "#{[digest_message, digest_backtrace].compact.join(' ')}" end
131
+ def _user_digests; "#{[digest_message, digest_backtrace].compact.join(' ')}" end
132
+ alias_method :user_digests, :_user_digests
115
133
  def status; self.class.status end
116
134
  def before_logging_blocks; self.class.before_logging_blocks end
117
135
  def after_logging_blocks; self.class.after_logging_blocks end
@@ -1,3 +1,3 @@
1
1
  module Coaster
2
- VERSION = '1.3.10'
2
+ VERSION = '1.3.13'
3
3
  end
@@ -178,5 +178,34 @@ module Coaster
178
178
  end
179
179
  end
180
180
  end
181
+
182
+ def test_backtrace_to_keep
183
+ e = ArgumentError.new(m: 'blahasdf', desc: 'qwer')
184
+ new_e = StandardError.new(e)
185
+ assert_equal new_e.message, e.message
186
+ assert_equal new_e.description, e.description
187
+ assert_nil new_e.backtrace
188
+ assert_nil e.backtrace
189
+ end
190
+
191
+ def test_backtrace_to_keep_as_cause
192
+ raise ArgumentError, m: 'blahasdf', desc: 'qwer'
193
+ rescue => e
194
+ new_e = StandardError.new(e)
195
+ assert_equal new_e.message, e.message
196
+ assert_equal new_e.description, e.description
197
+ assert_equal new_e.backtrace, e.backtrace
198
+ end
199
+
200
+ def sample_method_for_sse
201
+ sample_method_for_sse
202
+ end
203
+
204
+ def test_system_stack_error
205
+ sample_method_for_sse
206
+ rescue SystemStackError => e
207
+ new_e = StandardError.new(e)
208
+ assert_equal new_e.backtrace, e.backtrace
209
+ end
181
210
  end
182
211
  end
@@ -199,7 +199,9 @@ module Coaster
199
199
  MESSAGE: Test example error (Coaster::TestStandardError::ExampleError) cause{Test sample error (Coaster::TestStandardError::SampleError)}
200
200
  @attributes: {\"frog\"=>\"rams\", \"wat\"=>\"cha\"}
201
201
  @coaster: true
202
- @fingerprint: []
202
+ @digest_backtrace: NilClass
203
+ @digest_message: a8c7c1
204
+ @fingerprint: ["a8c7c1"]
203
205
  @ins_var: [\"Coaster::TestStandardError::SampleError\", {\"h\"=>1}]
204
206
  @ins_varr: {\"dd\"=>true}
205
207
  @level: \"error\"
@@ -215,7 +217,9 @@ CAUSE: [Coaster::TestStandardError::SampleError] status:10
215
217
  MESSAGE: Test sample error (Coaster::TestStandardError::SampleError)
216
218
  @attributes: {"frog"=>"rams"}
217
219
  @coaster: true
218
- @fingerprint: []
220
+ @digest_backtrace: NilClass
221
+ @digest_message: cbe233
222
+ @fingerprint: ["cbe233"]
219
223
  @level: "error"
220
224
  @raven: {}
221
225
  @tags: {}
@@ -311,7 +315,7 @@ LOG
311
315
  assert_equal 'NameError', e.to_hash['type']
312
316
  assert_equal 999999, e.to_hash['status']
313
317
  assert_equal 500, e.to_hash['http_status']
314
- assert_equal 'standard error translation (a962bd 80dfafa3)', e.user_message
318
+ assert_equal 'standard error translation (a962bd 3a7cb999)', e.user_message
315
319
  assert_match(/undefined local variable or method `aa'/, e.to_hash['message'])
316
320
  end
317
321
 
@@ -344,5 +348,34 @@ LOG
344
348
  e = SampleErrorMightHappen.new('fbar')
345
349
  assert !e.report?
346
350
  end
351
+
352
+ def test_user_message_change
353
+ SampleErrorSub.user_digests_with! do
354
+ message
355
+ end
356
+
357
+ begin
358
+ raise SampleError, 'asdff'
359
+ rescue => e
360
+ assert_equal e.user_message, 'Test sample error (0dba9e f0fa4c35)'
361
+ end
362
+ begin
363
+ raise SampleErrorSub, 'asdff'
364
+ rescue => e
365
+ assert_equal e.user_message, 'Test sample error (asdff)'
366
+ end
367
+ begin
368
+ raise SampleErrorSubSub, 'asdff'
369
+ rescue => e
370
+ assert_equal e.user_message, 'Test sample error (asdff)'
371
+ end
372
+
373
+ SampleErrorSubSub.user_digests_with_default!
374
+ begin
375
+ raise SampleErrorSubSub, 'asdff'
376
+ rescue => e
377
+ assert_equal e.user_message, 'Test sample error (58ee3f 3d0f84b9)'
378
+ end
379
+ end
347
380
  end
348
381
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.10
4
+ version: 1.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - buzz jung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-15 00:00:00.000000000 Z
11
+ date: 2022-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n