You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Buddhi De Silva (Jira)" <ji...@apache.org> on 2023/08/30 11:45:00 UTC
[jira] [Created] (CSV-309) Remove duplicate exception class name from message
Buddhi De Silva created CSV-309:
-----------------------------------
Summary: Remove duplicate exception class name from message
Key: CSV-309
URL: https://issues.apache.org/jira/browse/CSV-309
Project: Commons CSV
Issue Type: Improvement
Components: Parser
Affects Versions: 1.10.0
Reporter: Buddhi De Silva
When a parsing error occurred during the CSV data parsing, an 'UncheckedIOException' is thrown with a detailed message like below.
{code:java}
java.io.UncheckedIOException: IOException reading next record: java.io.IOException: (line 2) invalid char between encapsulated token and delimiter {code}
If you inspect 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.
{code:java}
java.io.UncheckedIOException: Error in reading next record: java.io.IOException: (line 2) invalid char between encapsulated token and delimiter {code}
What causes this issue?
In 'CSVParser.CSVRecordIterator.getNextRecord()' method has following format defined.
{code:java}
private CSVRecord getNextRecord() {
try {
return CSVParser.this.nextRecord();
} catch (final IOException e) {
throw new UncheckedIOException(e.getClass().getSimpleName() + " reading next record: " + e.toString(), e);
}
}
{code}
we could do a simple modification to the throw clause as follows to make this more meaningful.
{code:java}
throw new UncheckedIOException("Error in reading next record: " + e.toString(), e); {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)