show better error message, when no data points are found

This commit is contained in:
2017-03-26 17:30:50 +02:00
parent ee00ecb4b5
commit 364997e611
5 changed files with 40 additions and 9 deletions

View File

@@ -4,6 +4,10 @@ public class InternalPlottingException extends Exception {
private static final long serialVersionUID = 1L;
public InternalPlottingException() {
super();
}
public InternalPlottingException(final String message, final Throwable cause) {
super(message, cause);
}

View File

@@ -0,0 +1,10 @@
package org.lucares.recommind.logs;
public class NoDataPointsException extends InternalPlottingException {
private static final long serialVersionUID = 1054594230615520105L;
public NoDataPointsException() {
super();
}
}

View File

@@ -10,7 +10,9 @@ import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
@@ -74,8 +76,8 @@ public class Plotter {
final Result result = db.get(query, groupBy);
OffsetDateTime maxDate = OffsetDateTime.MIN;
OffsetDateTime minDate = OffsetDateTime.MAX;
OffsetDateTime maxDate = OffsetDateTime.ofInstant(Instant.ofEpochMilli(Long.MIN_VALUE), ZoneOffset.UTC);
OffsetDateTime minDate = OffsetDateTime.ofInstant(Instant.ofEpochMilli(Long.MAX_VALUE), ZoneOffset.UTC);
for (final GroupResult groupResult : result.getGroups()) {
@@ -94,6 +96,10 @@ public class Plotter {
}
}
if (dataSeries.isEmpty()) {
throw new NoDataPointsException();
}
sortAndLimit(dataSeries, plotSettings);
final File outputFile = File.createTempFile("out", ".png", outputDir.toFile());