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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25d78eb2f5780582358622b301ce8bc56b65a317bebf07bfdd5d719b18701cca
4
- data.tar.gz: 9862b67c209853c1a049e5769e503167e0a76fe687ab479755e3272b052dca5d
3
+ metadata.gz: 33d174be37c41745be18836a83e051931f9c7eff099bc65d4bfbdb292e467732
4
+ data.tar.gz: 8c822b6bad5a1d334057a5cd577e8f236b201cfc74cd8ce6bd1c6586190880ab
5
5
  SHA512:
6
- metadata.gz: c39ebfe2f732a1f44d0c9d4bdcd0b5a81c1a7fc6b3f76f150be78c83c4fccd6a90b6b4333efd91e0b57194462dd31c58c97bf8225ada59c01efcb3c43b4f313a
7
- data.tar.gz: f9915989ceac91f5891ede0dd40ce66c7e4e26f2d6628e508123ee75cb7229e125fe0567576b26f8ecf5e1ab87445ede8699d88d313c431c3968dc2ac8a60090
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
- return _translate
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
@@ -1,3 +1,3 @@
1
1
  module Coaster
2
- VERSION = '1.3.2'
2
+ VERSION = '1.3.3'
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - buzz jung