Skip to content

Commit

Permalink
catch some import parse errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliexdev committed Aug 14, 2015
1 parent 71ff2a7 commit 7d7e04c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ public void importData(String filename) throws IOException {
while (line != null) {
String csvField[] = line.split(",", -1);

if (csvField.length < 8) {
throw new IOException("Can't parse CSV file. Field length is wrong.");
}

ScaleData newScaleData = new ScaleData();

newScaleData.date_time = dateTimeFormat.parse(csvField[0]);
Expand All @@ -236,7 +240,9 @@ public void importData(String filename) throws IOException {

} catch (ParseException e) {
throw new IOException("Can't parse date format. Please set the date time format as <dd.MM.yyyy HH:mm> (e.g. 31.10.2014 05:23)");
}
} catch (NumberFormatException e) {
throw new IOException("Can't parse float number (" + e.getMessage()+")");
}

updateScaleData();

Expand Down

0 comments on commit 7d7e04c

Please sign in to comment.