[CSV-201] Do not use RuntimeException in CSVParser.iterator().new
Iterator() {...}.getNextRecord(). Use an IllegalStateException instead (KISS for now, no need for a custom exception)
This commit is contained in:
parent
b2a50d4a3a
commit
1c7a9910be
|
@ -43,6 +43,7 @@
|
|||
<action issue="CSV-193" type="fix" dev="ggregory" due-to="Matthias Wiehl">Fix incorrect method name 'withFirstRowAsHeader' in user guide.</action>
|
||||
<action issue="CSV-171" type="fix" dev="ggregory" due-to="Gary Gregory, Michael Graessle, Adrian Bridgett">Negative numeric values in the first column are always quoted in minimal mode.</action>
|
||||
<action issue="CSV-187" type="update" dev="ggregory" due-to="Gary Gregory">Update platform requirement from Java 6 to 7.</action>
|
||||
<action issue="CSV-201" type="update" dev="ggregory" due-to="Benedikt Ritter, Gary Gregory">Do not use RuntimeException in CSVParser.iterator().new Iterator() {...}.getNextRecord()</action>
|
||||
<action issue="CSV-189" type="add" dev="ggregory" due-to="Peter Holzwarth, Gary Gregory">CSVParser: Add factory method accepting InputStream.</action>
|
||||
<action issue="CSV-190" type="add" dev="ggregory" due-to="Gary Gregory">Add convenience API CSVFormat.print(File, Charset)</action>
|
||||
<action issue="CSV-191" type="add" dev="ggregory" due-to="Gary Gregory">Add convenience API CSVFormat.print(Path, Charset)</action>
|
||||
|
|
|
@ -501,10 +501,14 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
|
|||
/**
|
||||
* Returns an iterator on the records.
|
||||
*
|
||||
* <p>IOExceptions occurring during the iteration are wrapped in a
|
||||
* RuntimeException.
|
||||
* If the parser is closed a call to {@code next()} will throw a
|
||||
* NoSuchElementException.</p>
|
||||
* <p>
|
||||
* An {@link IOException} caught during the iteration are re-thrown as an
|
||||
* {@link IllegalStateException}.
|
||||
* </p>
|
||||
* <p>
|
||||
* If the parser is closed a call to {@link Iterator#next()} will throw a
|
||||
* {@link NoSuchElementException}.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public Iterator<CSVRecord> iterator() {
|
||||
|
@ -515,8 +519,8 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
|
|||
try {
|
||||
return CSVParser.this.nextRecord();
|
||||
} catch (final IOException e) {
|
||||
// TODO: This is not great, throw an ISE instead?
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalStateException(
|
||||
e.getClass().getSimpleName() + " reading next record: " + e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue