0

I'm unable to store the error getting registered in all the phases (parsing phase, business error, database error, invalid data error) in a csv file

Reason: The csv input row cannot be retrieved as the error method have only exception as parameter and not the actual csv row data. (Ex: parse exception alone has inputString method() and rest of the error handling phase doesn't have the input)

How to get the input row or the row being processed in all the stages of the spring batch job??

I need to create error csv with the following CSV row columns + line number + error message + reason

James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

1

If the error occurs during the read, then a FlatFileParseException will be passed to the SkipListener#onSkipInRead. This exception gives you the line number as well as the raw line read from the file.

If you want to intercept errors while processing, ie in SkipListener#onSkipInProcess, then it is up to you to write an exception class that has all details needed for error reporting. The item could be designed to carry the raw line it was read from.

Mahmoud Ben Hassine
  • 28,519
  • 3
  • 32
  • 50