@@ -129,11 +129,8 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
129
129
// should ideally mangle property names. But for now let's cheat; works
130
130
// for case-changing although not for kebab/snake cases and "localizedMessage"
131
131
if (PROP_NAME_MESSAGE .equalsIgnoreCase (propName )) {
132
- if (hasStringCreator ) {
133
- throwable = (Throwable ) _valueInstantiator .createFromString (ctxt , p .getValueAsString ());
134
- continue ;
135
- }
136
- // fall through
132
+ throwable = _instantiate (ctxt , hasStringCreator , p .getValueAsString ());
133
+ continue ;
137
134
}
138
135
139
136
// Things marked as ignorable should not be passed to any setter
@@ -161,22 +158,13 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
161
158
p .skipChildren ();
162
159
continue ;
163
160
}
161
+
164
162
// Unknown: let's call handler method
165
163
handleUnknownProperty (p , ctxt , throwable , propName );
166
164
}
167
165
// Sanity check: did we find "message"?
168
166
if (throwable == null ) {
169
- /* 15-Oct-2010, tatu: Can't assume missing message is an error, since it may be
170
- * suppressed during serialization.
171
- *
172
- * Should probably allow use of default constructor, too...
173
- */
174
- //throw new XxxException("No 'message' property found: could not deserialize "+_beanType);
175
- if (hasStringCreator ) {
176
- throwable = (Throwable ) _valueInstantiator .createFromString (ctxt , null );
177
- } else {
178
- throwable = (Throwable ) _valueInstantiator .createUsingDefault (ctxt );
179
- }
167
+ throwable = _instantiate (ctxt , hasStringCreator , null );
180
168
}
181
169
182
170
// any pending values?
@@ -196,4 +184,35 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
196
184
197
185
return throwable ;
198
186
}
187
+
188
+ /*
189
+ /**********************************************************
190
+ /* Internal helper methods
191
+ /**********************************************************
192
+ */
193
+
194
+ /**
195
+ * Helper method to initialize Throwable
196
+ *
197
+ * @since 2.17
198
+ */
199
+ private Throwable _instantiate (DeserializationContext ctxt , boolean hasStringCreator , String valueAsString )
200
+ throws IOException
201
+ {
202
+ /* 15-Oct-2010, tatu: Can't assume missing message is an error, since it may be
203
+ * suppressed during serialization.
204
+ *
205
+ * Should probably allow use of default constructor, too...
206
+ */
207
+ //throw new XxxException("No 'message' property found: could not deserialize "+_beanType);
208
+ if (hasStringCreator ) {
209
+ if (valueAsString != null ) {
210
+ return (Throwable ) _valueInstantiator .createFromString (ctxt , valueAsString );
211
+ } else {
212
+ return (Throwable ) _valueInstantiator .createFromString (ctxt , null );
213
+ }
214
+ } else {
215
+ return (Throwable ) _valueInstantiator .createUsingDefault (ctxt );
216
+ }
217
+ }
199
218
}
0 commit comments