Skip to content

Commit

Permalink
Added exception for the case where no route is found.
Browse files Browse the repository at this point in the history
  • Loading branch information
cfries committed Nov 26, 2023
1 parent aceb501 commit 95a41b0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/net/finmath/util/config/ConfigTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import net.finmath.util.config.nodes.ConfigNode;
Expand Down Expand Up @@ -46,7 +47,6 @@ public ConfigTree(List<String> keyOrder, List<Map<String, Object>> configs) {
* @return The configuration value for the given selector.
*/
public Object getConfig(Map<String, Object> selector) {

Node node = this.root;

// Traverse the tree where each route is selected though the value of a specific key in the selector.
Expand All @@ -57,6 +57,9 @@ public Object getConfig(Map<String, Object> selector) {
}
else {
node = configNode.getValueToConfig().get(SpecialNodes.DEFAULT_VALUE);
if(Objects.isNull(node)) {
throw new IllegalArgumentException("Neither a value nor a default branch exists in the config tree for " + configNode.getKey() + " at the current location. " + selector);
}
}
}

Expand All @@ -66,7 +69,7 @@ public Object getConfig(Map<String, Object> selector) {
return valueNode.getValue();
}
else {
throw new IllegalArgumentException("Unable to resolve configuration from the given properties.");
throw new IllegalArgumentException("Unable to resolve configuration from the given properties. " + selector);
}
}

Expand Down

0 comments on commit 95a41b0

Please sign in to comment.