Skip to content

Commit 746fcf4

Browse files
committed
Wrap NumberFormatException into IllegalStateException (#170)
1 parent 6779544 commit 746fcf4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

metafix/src/main/java/org/metafacture/metafix/FixPath.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,12 @@ private void removeNestedFrom(final Value value) {
238238
array.add(newValue);
239239
}
240240
else {
241-
mode.apply(array, field, newValue);
241+
try {
242+
mode.apply(array, field, newValue);
243+
}
244+
catch (final NumberFormatException e) {
245+
throw new IllegalStateException("Expected Hash, got Array", e);
246+
}
242247
}
243248
}
244249
}

metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public void shouldNotTrimIndexedArray() {
330330
@Test
331331
// See https://github.com/metafacture/metafacture-fix/pull/133
332332
public void shouldNotTrimStringInImplicitArrayOfHashes() {
333-
MetafixTestHelpers.assertExecutionException(NumberFormatException.class, "For input string: \"title\"", () ->
333+
MetafixTestHelpers.assertExecutionException(IllegalStateException.class, "Expected Hash, got Array", () ->
334334
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
335335
"trim('data.title')"
336336
),

0 commit comments

Comments
 (0)