mirror of
https://github.com/lightbend/config.git
synced 2025-03-13 18:50:45 +08:00
Do not pass Path object as exception argument
This commit is contained in:
parent
8625b78753
commit
743f240d47
@ -8,7 +8,6 @@ import java.io.Serializable;
|
||||
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
|
||||
@ -127,8 +126,8 @@ public abstract class ConfigException extends RuntimeException implements Serial
|
||||
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) {
|
||||
@ -139,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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,7 @@ import java.util.*;
|
||||
|
||||
import com.typesafe.config.ConfigException;
|
||||
|
||||
public final class Path {
|
||||
final class Path {
|
||||
|
||||
final private String first;
|
||||
final private Path remainder;
|
||||
@ -216,7 +216,7 @@ public final class Path {
|
||||
* 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();
|
||||
|
@ -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(self.origin(), originalPath);
|
||||
throw new ConfigException.Missing(self.origin(), originalPath.render());
|
||||
|
||||
if (expected != null)
|
||||
v = DefaultTransformer.transform(v, expected);
|
||||
|
Loading…
Reference in New Issue
Block a user