Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#584 Add root config origin to exception #585

Merged
merged 2 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions config/src/main/java/com/typesafe/config/ConfigException.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ public Missing(String path, Throwable cause) {
cause);
}

public Missing(ConfigOrigin origin, String path) {
this(origin, "No configuration setting found for key '" + path + "'", null);
}

public Missing(String path) {
this(path, null);
}
Expand All @@ -134,9 +138,6 @@ protected Missing(ConfigOrigin origin, String message, Throwable cause) {
super(origin, message, cause);
}

protected Missing(ConfigOrigin origin, String message) {
this(origin, message, null);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static private AbstractConfigValue findKeyOrNull(AbstractConfigObject self, Stri
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);
Expand Down