Commit 600f40d1 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

improve IOException handling slightly

parent 6e38619b
......@@ -189,7 +189,7 @@ public abstract class IOOutput {
try {
final Path pathToSnapshot = getPathToOutputFile(project, directory.getName(), IOUtils.SCENARIO_FILE_EXTENSION);
return Optional.of(IOVadere.fromJson(IOUtils.readTextFile(pathToSnapshot.toString())));
} catch (IOException | VadereClassNotFoundException e) {
} catch (IOException | VadereClassNotFoundException | IllegalArgumentException e ) {
logger.error("Error in output file " + directory.getName());
return Optional.empty();
}
......
......@@ -25,7 +25,7 @@ public class IOVadere {
private static Logger logger = LogManager.getLogger(IOVadere.class);
public static Scenario fromJson(final String json) throws IOException {
public static Scenario fromJson(final String json) throws IOException, IllegalArgumentException {
return JsonConverter.deserializeScenarioRunManager(json);
}
......
......@@ -19,11 +19,11 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
public class JsonConverter {
public static Scenario deserializeScenarioRunManager(String json) throws IOException {
public static Scenario deserializeScenarioRunManager(String json) throws IOException, IllegalArgumentException {
return deserializeScenarioRunManagerFromNode(StateJsonConverter.readTree(json));
}
public static Scenario deserializeScenarioRunManagerFromNode(JsonNode node) throws IOException {
public static Scenario deserializeScenarioRunManagerFromNode(JsonNode node) throws IOException, IllegalArgumentException {
JsonNode rootNode = node;
String name = rootNode.get("name").asText();
JsonNode scenarioNode = rootNode.get(StateJsonConverter.SCENARIO_KEY);
......
......@@ -119,7 +119,7 @@ public abstract class StateJsonConverter {
return deserializeTopographyFromNode(mapper.readTree(json));
}
public static Topography deserializeTopographyFromNode(JsonNode node) {
public static Topography deserializeTopographyFromNode(JsonNode node) throws IllegalArgumentException {
TopographyStore store = mapper.convertValue(node, TopographyStore.class);
Topography topography = new Topography(store.attributes, store.attributesPedestrian, store.attributesCar);
store.obstacles.forEach(obstacle -> topography.addObstacle(new Obstacle(obstacle)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment