Merge pull request #585 from ensirius/master

#584 Add root config origin to exception
This commit is contained in:
Havoc Pennington 2018-09-07 19:02:18 -04:00 committed by GitHub
commit 2a103fe53f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -126,6 +126,10 @@ public abstract class ConfigException extends RuntimeException implements Serial
cause);
}
public Missing(ConfigOrigin origin, String path) {
this(origin, "No configuration setting found for key '" + path + "'", null);
}
public Missing(String path) {
this(path, null);
}
@ -134,9 +138,6 @@ public abstract class ConfigException extends RuntimeException implements Serial
super(origin, message, cause);
}
protected Missing(ConfigOrigin origin, String message) {
this(origin, message, null);
}
}
/**

View File

@ -153,7 +153,7 @@ final class SimpleConfig implements Config, MergeableValue, Serializable {
ConfigValueType expected, Path originalPath) {
AbstractConfigValue v = self.peekAssumingResolved(key, originalPath);
if (v == null)
throw new ConfigException.Missing(originalPath.render());
throw new ConfigException.Missing(self.origin(), originalPath.render());
if (expected != null)
v = DefaultTransformer.transform(v, expected);