You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2023/09/04 17:06:09 UTC

[GitHub] [commons-csv] elharo commented on a diff in pull request #347: [CSV-147] Error message optimization during faulty CSV record read

elharo commented on code in PR #347:
URL: https://github.com/apache/commons-csv/pull/347#discussion_r1315124751


##########
src/main/java/org/apache/commons/csv/CSVParser.java:
##########
@@ -765,7 +765,13 @@ CSVRecord nextRecord() throws IOException {
         final long startCharPosition = lexer.getCharacterPosition() + this.characterOffset;
         do {
             this.reusableToken.reset();
-            this.lexer.nextToken(this.reusableToken);
+            try {
+                this.lexer.nextToken(this.reusableToken);
+            } catch (IOException ioe) {
+                String errorMessage = "Exception during parsing at line: "
+                        + this.lexer.getCurrentLineNumber() + ", position: " + this.lexer.getCharacterPosition();

Review Comment:
   I vote for number 1. try to keep exception logic in one place.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org