coaster 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coaster/core_ext/standard_error.rb +7 -8
- data/lib/coaster/version.rb +1 -1
- data/test/test_standard_error.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33d174be37c41745be18836a83e051931f9c7eff099bc65d4bfbdb292e467732
|
4
|
+
data.tar.gz: 8c822b6bad5a1d334057a5cd577e8f236b201cfc74cd8ce6bd1c6586190880ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58cfb38ecda73be57102b58e19d1badabc1a6ddf87717df4d8e6dc74b918fdf7f4e7d3569cffdb32968c3a5adc79b33930b14e534e6d1176656b22048a7a2951
|
7
|
+
data.tar.gz: 2886f1c69b87eda652641e8f28e48fb1514c8e8d1fe0d65973a93d63553426ea8dedd6012f27058b483f3ec293233e1468a1c67763a02ac1e0208804b9b1ff80
|
@@ -58,6 +58,7 @@ class StandardError
|
|
58
58
|
msg = hash.delete(:msg) || msg
|
59
59
|
msg = hash.delete(:message) || msg
|
60
60
|
hash[:description] ||= hash.delete(:desc) if hash[:desc].present?
|
61
|
+
hash[:dev_message] ||= hash.delete(:dm) if hash[:dm].present?
|
61
62
|
@fingerprint = hash.delete(:fingerprint) || hash.delete(:fingerprints)
|
62
63
|
@tags = hash.delete(:tags) || hash.delete(:tag)
|
63
64
|
@level = hash.delete(:level) || hash.delete(:severity) || @level
|
@@ -115,10 +116,10 @@ class StandardError
|
|
115
116
|
|
116
117
|
# description is user friendly message as a attribute, do not use error's message
|
117
118
|
# error message is not user friendly in many cases.
|
118
|
-
def description
|
119
|
-
attributes[:description] || attributes[:desc]
|
120
|
-
end
|
119
|
+
def description; attributes[:description] || attributes[:desc] end
|
121
120
|
alias_method :desc, :description
|
121
|
+
def dev_message; attributes[:dev_message] end
|
122
|
+
alias_method :dm, :dev_message
|
122
123
|
|
123
124
|
def _translate(*args)
|
124
125
|
return description if description.present?
|
@@ -132,10 +133,8 @@ class StandardError
|
|
132
133
|
# user friendly message, for overid
|
133
134
|
def user_message
|
134
135
|
return description if description.present?
|
135
|
-
if tkey.present?
|
136
|
-
|
137
|
-
end
|
138
|
-
message
|
136
|
+
return _translate if tkey.present?
|
137
|
+
"#{_translate} (#{to_origin_s})"
|
139
138
|
end
|
140
139
|
|
141
140
|
# another user friendly messages
|
@@ -151,7 +150,7 @@ class StandardError
|
|
151
150
|
alias to_origin_s to_s
|
152
151
|
|
153
152
|
def to_s
|
154
|
-
"#{_translate} (#{to_origin_s})"
|
153
|
+
"#{_translate} (#{dev_message || to_origin_s})"
|
155
154
|
end
|
156
155
|
|
157
156
|
def to_hash
|
data/lib/coaster/version.rb
CHANGED
data/test/test_standard_error.rb
CHANGED
@@ -91,6 +91,14 @@ module Coaster
|
|
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(dm: 'developer message')
|
95
|
+
assert_equal "Test sample error (developer message)", e.to_s
|
96
|
+
assert_equal "Test sample error (developer message)", e.message
|
97
|
+
assert_nil e.description
|
98
|
+
assert_nil e.desc
|
99
|
+
assert_equal 'Test sample error', e._translate
|
100
|
+
assert_equal 'Test sample error (Coaster::TestStandardError::SampleError)', e.user_message
|
101
|
+
assert_equal 'Test this title', e.title
|
94
102
|
e = SampleError.new(m: 'developer message', desc: 'user message')
|
95
103
|
assert_equal "user message (developer message)", e.to_s
|
96
104
|
assert_equal "user message (developer message)", e.message
|