Skip to content

Commit 52cb52b

Browse files
author
Dai MIKURUBE
committed
Add EndOfFileInQuotedFieldException instead of InvalidCsvQuotationException("Unexpected end of line during parsing a quoted value")
Note the original message "Unexpected end of line during parsing a quoted value" looks to be wrong because it is thrown when a next line is not found in a quoted field, not when an end of line is observed.
1 parent 3324468 commit 52cb52b

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

embulk-parser-csv/src/main/java/org/embulk/parser/csv/CsvTokenizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public String nextColumn() {
402402
quotedValue.append(this.newline);
403403
this.quotedValueLines.add(this.line);
404404
if (!this.nextLine(false)) {
405-
throw new InvalidCsvQuotationException("Unexpected end of line during parsing a quoted value");
405+
throw new EndOfFileInQuotedFieldException();
406406
}
407407
valueStartPos = 0;
408408

@@ -438,7 +438,7 @@ public String nextColumn() {
438438
quotedValue.append(this.line.substring(valueStartPos, this.linePos));
439439
this.quotedValueLines.add(this.line);
440440
if (!this.nextLine(false)) {
441-
throw new InvalidCsvQuotationException("Unexpected end of line during parsing a quoted value");
441+
throw new EndOfFileInQuotedFieldException();
442442
}
443443
valueStartPos = 0;
444444
} else if (this.isQuote(next) || this.isEscape(next)) { // escaped quote
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2022 The Embulk project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.embulk.parser.csv;
18+
19+
public class EndOfFileInQuotedFieldException extends InvalidCsvQuotationException {
20+
public EndOfFileInQuotedFieldException() {
21+
super("Unexpected end of file in a quoted field.");
22+
}
23+
}

0 commit comments

Comments
 (0)