Hi Commons-Devs,
I have one exception message optimization request for commons - CSV package.

Issue:
When a parsing error occurs during the CSV data parsing, an
'UncheckedIOException' is thrown with a detailed message like below.

"java.io.UncheckedIOException: IOException reading next record:
java.io.IOException: (line 2) invalid char between encapsulated token and
delimiter"

If you inspect the above error message carefully, you would see that the
exception type (IOException in this case) is printed twice in the first
message.
I think we could better format this error message as below.

"java.io.UncheckedIOException: Error in reading next record:
java.io.IOException: (line 2) invalid char between encapsulated token and
delimiter"

What causes this issue?
In 'CSVParser.CSVRecordIterator.getNextRecord()' method has the following
format defined.

private CSVRecord getNextRecord() {
    try {
        return CSVParser.this.nextRecord();
    } catch (final IOException e) {
        throw new UncheckedIOException(e.getClass().getSimpleName() + "
reading next record: " + e.toString(), e);
    }
}

we could do a simple modification to the throw clause as follows to make
this more meaningful.

"throw new UncheckedIOException("Error in reading next record: " +
e.toString(), e);"

GitHub PR Link: https://github.com/apache/commons-csv/pull/348
Jira issue: https://issues.apache.org/jira/browse/CSV-309

Appreciate your help in this!

Thank You.
Buddhi De Silva.

Reply via email to