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

@@ -16,6 +16,7 @@ import org.lucares.pdbui.domain.PlotRequest;
import org.lucares.pdbui.domain.PlotResponse;
import org.lucares.performance.db.CollectionUtils;
import org.lucares.recommind.logs.InternalPlottingException;
import org.lucares.recommind.logs.NoDataPointsException;
import org.lucares.recommind.logs.Plotter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,13 +54,17 @@ public class PdbController implements HardcodedValues, CollectionUtils {
final PlotSettings plotSettings = PlotSettingsTransformer.toSettings(request);
final File image = plotter.plot(plotSettings);
try {
final File image = plotter.plot(plotSettings);
final Path relativeImagePath = plotter.getOutputDir().relativize(image.toPath());
final String relativeImgUrl = relativeImagePath.toString().replace('\\', '/');
final String imageUrl = WEB_IMAGE_OUTPUT_PATH + "/" + relativeImgUrl;
LOGGER.trace("image url: {}", imageUrl);
return new PlotResponse(imageUrl);
final Path relativeImagePath = plotter.getOutputDir().relativize(image.toPath());
final String relativeImgUrl = relativeImagePath.toString().replace('\\', '/');
final String imageUrl = WEB_IMAGE_OUTPUT_PATH + "/" + relativeImgUrl;
LOGGER.trace("image url: {}", imageUrl);
return new PlotResponse(imageUrl);
} catch (final NoDataPointsException e) {
throw new NotFoundException(e);
}
}
@RequestMapping(path = "/autocomplete", //

View File

@@ -99,7 +99,13 @@ function plot(event){
$('#result-view').html('<img src=\"'+response.imageUrls+'" />');
};
var error = function(e) {
$('#result-view').text("FAILED: " + JSON.stringify(e));
if (e.status == 404){
$('#result-view').text("No data points found.");
}
else{
$('#result-view').text("FAILED: " + JSON.stringify(e));
}
};