Skip to content

Commit bde599c

Browse files
author
Dai MIKURUBE
committed
Validate RecordDoesNotHaveExpectedColumnException and RecordHasUnexpectedTrailingColumnException
1 parent 1fbd4f4 commit bde599c

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

embulk-guess-csv/src/main/java/org/embulk/guess/csv/CsvGuessPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.embulk.parser.csv.CsvParserPlugin;
3333
import org.embulk.parser.csv.CsvTokenizer;
3434
import org.embulk.parser.csv.InvalidCsvQuotationException;
35-
import org.embulk.parser.csv.TooFewColumnsException;
35+
import org.embulk.parser.csv.RecordDoesNotHaveExpectedColumnException;
3636
import org.embulk.spi.Buffer;
3737
import org.embulk.spi.BufferAllocator;
3838
import org.embulk.spi.Exec;
@@ -319,7 +319,7 @@ private static List<List<String>> splitLines(
319319
} else {
320320
columns.add(column);
321321
}
322-
} catch (final TooFewColumnsException ex) {
322+
} catch (final RecordDoesNotHaveExpectedColumnException ex) {
323323
rows.add(Collections.unmodifiableList(columns));
324324
break;
325325
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ private String nextColumn() {
431431

432432
try {
433433
hasNextRecord = tokenizer.nextRecord();
434-
} catch (TooManyColumnsException ex) {
434+
} catch (final RecordHasUnexpectedTrailingColumnException ex) {
435435
if (allowExtraColumns) {
436436
String tooManyColumnsLine = tokenizer.skipCurrentLine();
437437
// TODO warning

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
@@ -221,7 +221,7 @@ public boolean nextRecord() {
221221
public boolean nextRecord(final boolean skipEmptyLine) {
222222
// If at the end of record, read the next line and initialize the state
223223
if (this.recordState != RecordState.END) {
224-
throw new TooManyColumnsException("Too many columns");
224+
throw new RecordHasUnexpectedTrailingColumnException();
225225
}
226226

227227
final boolean hasNext = this.nextLine(skipEmptyLine);
@@ -260,7 +260,7 @@ public boolean hasNextColumn() {
260260

261261
public String nextColumn() {
262262
if (!this.hasNextColumn()) {
263-
throw new TooFewColumnsException("Too few columns");
263+
throw new RecordDoesNotHaveExpectedColumnException();
264264
}
265265

266266
// reset last state

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.embulk.parser.csv;
1818

19-
public class TooFewColumnsException extends InvalidCsvFormatException {
20-
public TooFewColumnsException(final String message) {
21-
super(message);
19+
public class RecordDoesNotHaveExpectedColumnException extends InvalidCsvFormatException {
20+
public RecordDoesNotHaveExpectedColumnException() {
21+
super("A record does not have an expected column (i.e. too few columns).");
2222
}
2323
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.embulk.parser.csv;
1818

19-
public class TooManyColumnsException extends InvalidCsvFormatException {
20-
public TooManyColumnsException(final String message) {
21-
super(message);
19+
public class RecordHasUnexpectedTrailingColumnException extends InvalidCsvFormatException {
20+
public RecordHasUnexpectedTrailingColumnException() {
21+
super("A record has an unexpected trailing column (i.e. too many columns).");
2222
}
2323
}

0 commit comments

Comments
 (0)