Say I am parsing a CSV employee file. I have a pojo called Employee and i'm using univocity routines and an iterator.
Iterator<Employee> iterator = routines.iterate(Employee.class, ...)
When an error occurs when parsing a row, I don't want to use the setProcessorErrorHandler() callback. Instead I want to return a generic "Record" or "Item" wrapper which wraps Employee and any error context info if applicable. A bit like how the JTinyCsvParser library's CsvMappingResult object behaves.
Is there an easy way of doing this short of catching for example com.univocity.parsers.common.DataProcessingException?
You can but you still need to use the RetryableErrorHandler
and from it you must call keepRecord()
to prevent the record from being discarded. This way you will get your problematic Employee
instance with the information that could be parsed.