Was wondering if there’s a way one can handle conversion errors in a lenient way.
Given a query that returns a List[ModelObject]
If there are 5 DBObjects retrieved, one of them is throwing a ConversionException when converted to ModelObject, is there a way to return the 4 convertible objects and provide a hook for the 1 conversion failure?
A bit late, but this answer might help someone else’s search
I agree it would be nice to do this on a policy basis – at the moment, if you get a single conversion error, you get no list at all. I think there are use cases where this is a valid need.
However, since you can’t, you need to register a custom converter for your ModelObject that converts leniently…
and then register this as a custom converter in your bean definitions. Something like: