mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
make ConfigException abstract
This commit is contained in:
parent
9f9b351f0e
commit
9689abd781
@ -7,7 +7,7 @@ package com.typesafe.config;
|
||||
/**
|
||||
* All exceptions thrown by the library are subclasses of ConfigException.
|
||||
*/
|
||||
public class ConfigException extends RuntimeException {
|
||||
public abstract class ConfigException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
final private ConfigOrigin origin;
|
||||
@ -343,4 +343,20 @@ public class ConfigException extends RuntimeException {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception that doesn't fall into any other category.
|
||||
*/
|
||||
public static class Generic extends ConfigException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Generic(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public Generic(String message) {
|
||||
this(message, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -123,8 +123,9 @@ public final class ConfigFactory {
|
||||
if (specified == 0) {
|
||||
return load("application");
|
||||
} else if (specified > 1) {
|
||||
throw new ConfigException(
|
||||
"You set more than one system property from config.file, config.url, config.resource; don't know which one to use!");
|
||||
throw new ConfigException.Generic("You set more than one of config.file='" + file
|
||||
+ "', config.url='" + url + "', config.resource='" + resource
|
||||
+ "'; don't know which one to use!");
|
||||
} else {
|
||||
if (resource != null) {
|
||||
// this deliberately does not parseResourcesAnySyntax; if
|
||||
@ -136,8 +137,9 @@ public final class ConfigFactory {
|
||||
try {
|
||||
return load(parseURL(new URL(url)));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new ConfigException("Bad URL in config.url system property: '" + url
|
||||
+ "'", e);
|
||||
throw new ConfigException.Generic(
|
||||
"Bad URL in config.url system property: '" + url + "': "
|
||||
+ e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user