RuntimeExceptions thrown from custom code called by
Dozer during mapping (eg. custom converters) should not
be wrapped with MappingException, since it makes it
difficult to differentiate different types of mapping
error from outside the call to MapperIF.map.
My use case is a custom converter that throws a variety
of different exceptions (all sub-classes of
RuntimeException) and I need to be able to respond to
each type of exception differently. Because all of my
exceptions get wrapped in a MappingException I'm forced
to catch all MappingExceptions (even the ones I'm not
interested in), "unwrap" it to get the underlying
exception type and then execute a bluddy great if /
then / else statement for each different type. It
would more elegant to be able to use Java's native
support for multiple catch clauses instead.
It may even make sense to change MapperIF.map to throw
java.lang.Exception so that checked exceptions don't
have to be wrapped either.
Log in to post a comment.