Use a custom LineMapper to proxy the DefaultLineMapper:
Code:
public class CustomLineMapper<T> implements LineMapper<Object> {
private LineMapper<T> delegate;
public Object mapLine(String line, int lineNumber) throws Exception {
try {
return delegate.mapLine(line, lineNumber);
} catch (Exception e) {
return new ErrorObject(line, lineNumber);
}
}
}
Wire the DefaultLineMapper bean into this custom LineMapper as the 'delegate' property. That way your custom mapper will use the DefaultLineMapper and handle exceptions if necessary. Any exception raised during mapping will result in an ErrorObject being returned instead of the true item.