Add InvalidConfigurationPropertyValueException
This commit adds a new exception type that denotes the value of a configuration key is invalid, alongside a FailureAnalyzer that reports a human-readable report when such exception is thrown on startup. ResourceNotFoundException being a (useless) specialization of this new exception, its usage has been refactored to use the more general exception type. Closes gh-10794
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ import javax.sql.DataSource;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.boot.context.config.ResourceNotFoundException;
|
||||
import org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.boot.jdbc.DataSourceInitializationMode;
|
||||
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
|
||||
@@ -166,7 +166,8 @@ class DataSourceInitializer {
|
||||
resources.add(resource);
|
||||
}
|
||||
else if (validate) {
|
||||
throw new ResourceNotFoundException(propertyName, resource);
|
||||
throw new InvalidConfigurationPropertyValueException(propertyName,
|
||||
resource, "the specified resource does not exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user