Skip to content

Commit

Permalink
Do not pass Path object as exception argument
Browse files Browse the repository at this point in the history
  • Loading branch information
vgolub committed Sep 7, 2018
1 parent 8625b78 commit 743f240
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
8 changes: 2 additions & 6 deletions config/src/main/java/com/typesafe/config/ConfigException.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.lang.reflect.Field;

import com.typesafe.config.impl.ConfigImplUtil;
import com.typesafe.config.impl.Path;

/**
* All exceptions thrown by the library are subclasses of
Expand Down Expand Up @@ -127,8 +126,8 @@ public Missing(String path, Throwable cause) {
cause);
}

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

public Missing(String path) {
Expand All @@ -139,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
4 changes: 2 additions & 2 deletions config/src/main/java/com/typesafe/config/impl/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.typesafe.config.ConfigException;

public final class Path {
final class Path {

final private String first;
final private Path remainder;
Expand Down Expand Up @@ -216,7 +216,7 @@ public String toString() {
* toString() is a debugging-oriented version while this is an
* error-message-oriented human-readable one.
*/
public String render() {
String render() {
StringBuilder sb = new StringBuilder();
appendToStringBuilder(sb);
return sb.toString();
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(self.origin(), originalPath);
throw new ConfigException.Missing(self.origin(), originalPath.render());

if (expected != null)
v = DefaultTransformer.transform(v, expected);
Expand Down

0 comments on commit 743f240

Please sign in to comment.