Skip to content

Commit 5a3fa9b

Browse files
committed
Handle NumberFormatException in apply (#170)
1 parent 9b8fa39 commit 5a3fa9b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ void apply(final Hash hash, final String field, final Value value) {
164164

165165
@Override
166166
void apply(final Array array, final String field, final Value value) {
167-
array.set(Integer.valueOf(field) - 1, value);
167+
try {
168+
array.set(Integer.valueOf(field) - 1, value);
169+
}
170+
catch (final NumberFormatException e) {
171+
throw new IllegalStateException("Expected Hash, got Array", e);
172+
}
168173
}
169174
},
170175
APPEND {
@@ -238,12 +243,7 @@ private void removeNestedFrom(final Value value) {
238243
array.add(newValue);
239244
}
240245
else {
241-
try {
242-
mode.apply(array, field, newValue);
243-
}
244-
catch (final NumberFormatException e) {
245-
throw new IllegalStateException("Expected Hash, got Array", e);
246-
}
246+
mode.apply(array, field, newValue);
247247
}
248248
}
249249
}

0 commit comments

Comments
 (0)