Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/csv/CSVParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private CSVRecord getNextRecord() {
try {
return CSVParser.this.nextRecord();
} catch (final IOException e) {
throw new UncheckedIOException(e.getClass().getSimpleName() + " reading next record: " + e.toString(), e);
throw new UncheckedIOException("Error in reading next record: " + e.toString(), e);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just throw new UncheckedIOException("Error in reading next record", e);? No duplication. Plain and simple.

@gbidsilva gbidsilva Aug 30, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be the intention was to provide the sense of error in the message itself.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an Error... See below.

@garydgregory garydgregory Aug 30, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Error" has a specific meaning in Java, and we did not catch a java.lang.Error here. Saying "Exception reading next record..." is more accurate than "Error ...", then the difference is whether the sentence starts with "Exception ..." vs. "IOException..." (or a subclass), so the difference is not interesting IMO. Or, we could say "CSVParser#nextRecord(): " + e where the (maybe dubious) benefit is that it is a touch more language-neutral.

Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel "Exception reading next record" would be more meaningful.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just: "Failed to read next record"?

}
}

Expand Down