I am handling a file with 1 million records and my customer creates this file from his code. I might receive hundreds of these files. I have to read these records and ingest them into a database. It is possible that some of the records might be incorrectly formatted and lead to parse exceptions. What should be the exception handling philosophy here?
- I could handle the incorrectly formatted records and store them in a queue while processing all the other correct records in a file. This would require me to write extra code but once the customer fixes this error in his code the error handling code in my application will not be used ever and I would have wasted time writing and maintaining error handling code that might never be used or used sparingly.
- I could fail the entire file by letting the RuntimeException percolate upwards and let the customer correct his code and then re-submit the file again. This would keep my processing simpler but would mean that I am not processing the correct records even though I could handle it in the first pass.