Skip to content
Snippets Groups Projects

Sane API errors

Merged
Luc Everserequested to merge
sane-api-errors into development
All threads resolved!
56 files
+ 1414
294
Compare changes
  • Side-by-side
  • Inline

Files

@@ -2,6 +2,9 @@ package nl.tudelft.ewi.auta.core.benchmarking;
import nl.tudelft.ewi.auta.common.model.entity.EntityLevel;
import nl.tudelft.ewi.auta.common.model.metric.MetricName;
import nl.tudelft.ewi.auta.core.response.exception.InvalidEntityLevelException;
import nl.tudelft.ewi.auta.core.response.exception.InvalidMetricNameException;
import nl.tudelft.ewi.auta.core.response.exception.MissingFieldException;
import java.util.List;
import java.util.Set;
@@ -103,22 +106,36 @@ public class BenchmarkingData {
*/
public void validate() throws IllegalArgumentException, IllegalSystemRankTableException {
if (this.metricNameString == null) {
throw new IllegalArgumentException("Missing metric name");
throw new MissingFieldException("Missing metric name");
}
try {
MetricName.valueOf(this.metricNameString);
} catch (final IllegalArgumentException ex) {
throw new InvalidMetricNameException(
this.metricNameString + " is not a valid metric name", ex
);
}
MetricName.valueOf(this.metricNameString);
if (this.entityLevelString == null) {
throw new IllegalArgumentException("Missing entity level");
throw new MissingFieldException("Missing entity level");
}
try {
EntityLevel.valueOf(this.entityLevelString);
} catch (final IllegalArgumentException ex) {
throw new InvalidEntityLevelException(
this.entityLevelString + " is not a valid entity level", ex
);
}
EntityLevel.valueOf(this.entityLevelString);
if (this.riskCategories == null) {
throw new IllegalArgumentException("Missing risk categories");
throw new MissingFieldException("Missing risk categories");
}
new NumberRiskCategories(this.riskCategories);
if (this.rankingTable == null) {
throw new IllegalArgumentException("Missing system ranking table");
throw new MissingFieldException("Missing system ranking table");
}
new SystemRanking(this.rankingTable);
}
Loading