feature: improved handling exception NoSuchElementException
This commit is contained in:
@@ -34,7 +34,7 @@ public class FileDataSource implements DataSource{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (NoSuchElementException e){
|
catch (NoSuchElementException e){
|
||||||
System.out.println("No such element");
|
System.out.println(e.getMessage() + "No such element");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class StudentCsvReader implements Iterator<Student> {
|
|||||||
public Student next() {
|
public Student next() {
|
||||||
lineOfFile++;
|
lineOfFile++;
|
||||||
if (!records.hasNext()) {
|
if (!records.hasNext()) {
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException("Problem at line " + lineOfFile + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRecord record = records.next();
|
CSVRecord record = records.next();
|
||||||
|
|||||||
Reference in New Issue
Block a user