coaster 1.3.4 → 1.3.5
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/coaster/core_ext/standard_error.rb +12 -17
- data/lib/coaster/version.rb +1 -1
- data/test/test_standard_error.rb +24 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca831c98247a51e387740d4a2b15d9d7c31a37a4a119e69bf9081cc6ef08a438
|
4
|
+
data.tar.gz: dedfc0e5be84563640b98ac5808dda34c735ac2ca40edac5c76d906d69c9b63d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d8591789c4e587d37b88033881c6031d7ce231915058b2eac1b041c5e2d8933a03808a157a6f8cf17b3b5541c0ee25b1fd3b24992956467bfda165369c22968
|
7
|
+
data.tar.gz: f778ee607e1f0a249518df4292427e4fd812ebbca8868b40908e593dce6670d4a818b166a58aa24cb5f195f9159119983684ff1fee0cf6c2273bf02d54a949a6
|
@@ -53,17 +53,23 @@ class StandardError
|
|
53
53
|
msg = message
|
54
54
|
set_backtrace(message.backtrace)
|
55
55
|
when Hash then
|
56
|
+
@coaster = true # coaster 확장을 사용한 에러임을 확인할 수 있음.
|
56
57
|
hash = message.with_indifferent_access rescue message
|
57
58
|
msg = hash.delete(:m)
|
58
59
|
msg = hash.delete(:msg) || msg
|
59
60
|
msg = hash.delete(:message) || msg
|
60
61
|
hash[:description] ||= hash.delete(:desc) if hash[:desc].present?
|
61
|
-
hash[:dev_message] ||= hash.delete(:dm) if hash[:dm].present?
|
62
62
|
@fingerprint = hash.delete(:fingerprint) || hash.delete(:fingerprints)
|
63
63
|
@tags = hash.delete(:tags) || hash.delete(:tag)
|
64
64
|
@level = hash.delete(:level) || hash.delete(:severity) || @level
|
65
65
|
@tkey = hash.delete(:tkey)
|
66
66
|
@attributes.merge!(hash)
|
67
|
+
if @attributes[:description] == :translate
|
68
|
+
@attributes.delete(:description)
|
69
|
+
@attributes[:description] = _translate
|
70
|
+
end
|
71
|
+
msg = "#{_translate} (#{msg || self.class.name})"
|
72
|
+
msg = "#{msg} {#{cause.message}}" if cause
|
67
73
|
when String then
|
68
74
|
msg = message
|
69
75
|
when FalseClass, NilClass then
|
@@ -74,7 +80,7 @@ class StandardError
|
|
74
80
|
|
75
81
|
@fingerprint = [] unless @fingerprint.is_a?(Array)
|
76
82
|
@tags = {} unless @tags.is_a?(Hash)
|
77
|
-
msg = cause.message if msg.blank? && cause
|
83
|
+
msg = "{#{cause.message}}" if msg.blank? && cause
|
78
84
|
super(msg)
|
79
85
|
end
|
80
86
|
|
@@ -118,8 +124,6 @@ class StandardError
|
|
118
124
|
# error message is not user friendly in many cases.
|
119
125
|
def description; attributes[:description] || attributes[:desc] end
|
120
126
|
alias_method :desc, :description
|
121
|
-
def dev_message; attributes[:dev_message] end
|
122
|
-
alias_method :dm, :dev_message
|
123
127
|
|
124
128
|
def _translate(*args)
|
125
129
|
return description if description.present?
|
@@ -132,9 +136,9 @@ class StandardError
|
|
132
136
|
|
133
137
|
# user friendly message, for overid
|
134
138
|
def user_message
|
135
|
-
return
|
136
|
-
return _translate
|
137
|
-
|
139
|
+
return _translate if description.present? || tkey.present?
|
140
|
+
return "#{_translate} (#{message})" unless defined?(@coaster)
|
141
|
+
message
|
138
142
|
end
|
139
143
|
|
140
144
|
# another user friendly messages
|
@@ -144,15 +148,6 @@ class StandardError
|
|
144
148
|
attributes[:descriptions]
|
145
149
|
end
|
146
150
|
|
147
|
-
# https://github.com/getsentry/sentry-ruby/blob/fbbc7a51ed10684d0e8b7bd9d2a1b65a7351c9ef/lib/raven/event.rb#L162
|
148
|
-
# sentry message use `to_s` method
|
149
|
-
# https://ruby-doc.org/core-2.5.1/Exception.html#method-i-to_s
|
150
|
-
alias to_origin_s to_s
|
151
|
-
|
152
|
-
def to_s
|
153
|
-
"#{_translate} (#{dev_message || to_origin_s})"
|
154
|
-
end
|
155
|
-
|
156
151
|
def to_hash
|
157
152
|
hash = attributes.merge(
|
158
153
|
type: self.class.name, status: status,
|
@@ -176,7 +171,7 @@ class StandardError
|
|
176
171
|
lg = "[#{self.class.name}] status:#{status}"
|
177
172
|
lg += "\n\tMESSAGE: #{safe_message.gsub(/\n/, "\n\t\t")}"
|
178
173
|
instance_variables.each do |var|
|
179
|
-
if var.to_s.start_with?('@_')
|
174
|
+
if var.to_s.start_with?('@_') || var.to_s == '@coaster'
|
180
175
|
next
|
181
176
|
elsif var.to_s == '@spell_checker'
|
182
177
|
next
|
data/lib/coaster/version.rb
CHANGED
data/test/test_standard_error.rb
CHANGED
@@ -22,8 +22,8 @@ module Coaster
|
|
22
22
|
|
23
23
|
def test_standard_messages
|
24
24
|
e = StandardError.new('developer message')
|
25
|
-
assert_equal "
|
26
|
-
assert_equal "
|
25
|
+
assert_equal "developer message", e.to_s
|
26
|
+
assert_equal "developer message", e.message
|
27
27
|
assert_nil e.description
|
28
28
|
assert_nil e.desc
|
29
29
|
assert_equal 'standard error translation', e._translate
|
@@ -41,8 +41,8 @@ module Coaster
|
|
41
41
|
|
42
42
|
def test_no_translation_class
|
43
43
|
e = UntitledError.new('developer message')
|
44
|
-
assert_equal "
|
45
|
-
assert_equal "
|
44
|
+
assert_equal "developer message", e.to_s
|
45
|
+
assert_equal "developer message", e.message
|
46
46
|
assert_nil e.description
|
47
47
|
assert_nil e.desc
|
48
48
|
assert_equal 'standard error translation', e._translate
|
@@ -68,8 +68,8 @@ module Coaster
|
|
68
68
|
|
69
69
|
def test_with_translation_class
|
70
70
|
e = SampleError.new
|
71
|
-
assert_equal "
|
72
|
-
assert_equal "
|
71
|
+
assert_equal "Coaster::TestStandardError::SampleError", e.to_s
|
72
|
+
assert_equal "Coaster::TestStandardError::SampleError", e.message
|
73
73
|
assert_nil e.description
|
74
74
|
assert_nil e.desc
|
75
75
|
assert_equal 'Test sample error', e._translate
|
@@ -84,18 +84,26 @@ module Coaster
|
|
84
84
|
assert_equal 'Test sample error (Coaster::TestStandardError::SampleError)', e.user_message
|
85
85
|
assert_equal 'Test this title', e.title
|
86
86
|
e = SampleError.new('developer message')
|
87
|
-
assert_equal "
|
88
|
-
assert_equal "
|
87
|
+
assert_equal "developer message", e.to_s
|
88
|
+
assert_equal "developer message", e.message
|
89
89
|
assert_nil e.description
|
90
90
|
assert_nil e.desc
|
91
91
|
assert_equal 'Test sample error', e._translate
|
92
92
|
assert_equal 'Test sample error (developer message)', e.user_message
|
93
93
|
assert_equal 'Test this title', e.title
|
94
|
-
e = SampleError.new(
|
94
|
+
e = SampleError.new(desc: 'user message')
|
95
|
+
assert_equal "user message (Coaster::TestStandardError::SampleError)", e.to_s
|
96
|
+
assert_equal "user message (Coaster::TestStandardError::SampleError)", e.message
|
97
|
+
assert_equal 'user message', e.description
|
98
|
+
assert_equal 'user message', e.desc
|
99
|
+
assert_equal 'user message', e._translate
|
100
|
+
assert_equal 'user message', e.user_message
|
101
|
+
assert_equal 'Test this title', e.title
|
102
|
+
e = SampleError.new(m: 'developer message', desc: :translate)
|
95
103
|
assert_equal "Test sample error (developer message)", e.to_s
|
96
104
|
assert_equal "Test sample error (developer message)", e.message
|
97
|
-
|
98
|
-
|
105
|
+
assert_equal "Test sample error", e.description
|
106
|
+
assert_equal "Test sample error", e.desc
|
99
107
|
assert_equal 'Test sample error', e._translate
|
100
108
|
assert_equal 'Test sample error', e.user_message
|
101
109
|
assert_equal 'Test this title', e.title
|
@@ -140,7 +148,7 @@ module Coaster
|
|
140
148
|
assert_equal 'Coaster::TestStandardError::ExampleError', e.to_hash['type']
|
141
149
|
assert_equal 20, e.to_hash['status']
|
142
150
|
assert_equal 500, e.to_hash['http_status']
|
143
|
-
assert_equal "Test example error (Test sample error (
|
151
|
+
assert_equal "Test example error (Coaster::TestStandardError::ExampleError) {Test sample error (Coaster::TestStandardError::SampleError)}", e.to_hash['message']
|
144
152
|
assert_equal 'rams', e.to_hash['cause']['frog']
|
145
153
|
assert_equal 'Coaster::TestStandardError::SampleError', e.to_hash['cause']['type']
|
146
154
|
assert_equal 10, e.to_hash['cause']['status']
|
@@ -152,9 +160,10 @@ module Coaster
|
|
152
160
|
begin
|
153
161
|
raise SampleError, {frog: 'rams'}
|
154
162
|
rescue => e
|
155
|
-
raise ExampleError, {wat: 'cha'}
|
163
|
+
raise ExampleError, {m: 'abc', wat: 'cha'}
|
156
164
|
end
|
157
165
|
rescue => e
|
166
|
+
assert_equal 'Test example error (abc) {Test sample error (Coaster::TestStandardError::SampleError)}', e.message
|
158
167
|
assert_equal 'rams', e.cause.attr['frog']
|
159
168
|
assert_equal 'rams', e.attr['frog']
|
160
169
|
assert_equal 'cha', e.attr['wat']
|
@@ -169,7 +178,7 @@ module Coaster
|
|
169
178
|
rescue => e
|
170
179
|
detail = <<-LOG
|
171
180
|
[Coaster::TestStandardError::ExampleError] status:20
|
172
|
-
MESSAGE: Test example error (Test sample error (Coaster::TestStandardError::SampleError)
|
181
|
+
MESSAGE: Test example error (Coaster::TestStandardError::ExampleError) {Test sample error (Coaster::TestStandardError::SampleError)}
|
173
182
|
@fingerprint: []
|
174
183
|
@tags: {}
|
175
184
|
@level: \"error\"
|
@@ -226,7 +235,7 @@ LOG
|
|
226
235
|
begin
|
227
236
|
root_cause_sample3
|
228
237
|
rescue => e
|
229
|
-
assert_equal "
|
238
|
+
assert_equal "a", e.root_cause.message
|
230
239
|
end
|
231
240
|
end
|
232
241
|
|
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.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- buzz jung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|