Skip to content

Commit 63d7830

Browse files
committed
Move to better exception syntax.
1 parent f65800a commit 63d7830

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

src/main/java/org/zalando/typemapper/postgres/PgTypeHelper.java

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@ public int compare(final Field a, final Field b) {
270270
Object value;
271271
try {
272272
value = getOptionalValue(f.get(obj));
273-
} catch (final IllegalArgumentException e) {
274-
throw new IllegalArgumentException("Could not read value of field " + f.getName(), e);
275-
} catch (final IllegalAccessException e) {
273+
} catch (final IllegalArgumentException | IllegalAccessException e) {
276274
throw new IllegalArgumentException("Could not read value of field " + f.getName(), e);
277275
}
278276

@@ -419,17 +417,7 @@ private static Object applyTransformer(final Field f, final DatabaseFieldDescrip
419417

420418
// transform the value by the transformer into a database value:
421419
value = transformer.marshalToDb(value);
422-
} catch (final InstantiationException e) {
423-
throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e);
424-
} catch (final IllegalAccessException e) {
425-
throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e);
426-
} catch (final InvocationTargetException e) {
427-
throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e);
428-
} catch (IllegalArgumentException e) {
429-
throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e);
430-
} catch (NoSuchMethodException e) {
431-
throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e);
432-
} catch (SecurityException e) {
420+
} catch (final InstantiationException | IllegalAccessException | InvocationTargetException | IllegalArgumentException | NoSuchMethodException | SecurityException e) {
433421
throw new IllegalArgumentException("Could not instantiate transformer of field " + f.getName(), e);
434422
}
435423
}
@@ -441,17 +429,7 @@ private static Object applyTransformer(final Field f, final DatabaseFieldDescrip
441429
ObjectMapper<Object> mapper = (ObjectMapper<Object>) mapperClass.getDeclaredConstructor().newInstance();
442430

443431
value = mapper.marshalToDb(value);
444-
} catch (InstantiationException e) {
445-
throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e);
446-
} catch (IllegalAccessException e) {
447-
throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e);
448-
} catch (IllegalArgumentException e) {
449-
throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e);
450-
} catch (InvocationTargetException e) {
451-
throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e);
452-
} catch (NoSuchMethodException e) {
453-
throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e);
454-
} catch (SecurityException e) {
432+
} catch (final InstantiationException | IllegalAccessException | InvocationTargetException | IllegalArgumentException | NoSuchMethodException | SecurityException e) {
455433
throw new IllegalArgumentException("Could not instantiate mapper of field " + f.getName(), e);
456434
}
457435
}

0 commit comments

Comments
 (0)