ENT-4368 - Improve error handling when required included config resource cannot be found. Add note in docs encouraging use of required syntax for includes. (#5907)

This commit is contained in:
Oliver Knowles 2020-01-30 10:10:24 +00:00 committed by GitHub
parent 5b186b1c65
commit 286fffd67a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -36,6 +36,10 @@ This prevents configuration errors when mixing keys containing ``.`` wrapped wit
By default the node will fail to start in presence of unknown property keys.
To alter this behaviour, the ``on-unknown-config-keys`` command-line argument can be set to ``IGNORE`` (default is ``FAIL``).
.. note:: As noted in the HOCON documentation, the default behaviour for resources referenced within a config file is to silently
ignore them if missing. Therefore it is strongly recommended to utilise the ``required`` syntax for includes. See HOCON documentation
for more information.
Overriding configuration values
-------------------------------

View File

@ -74,15 +74,16 @@ open class SharedNodeCmdLineOptions {
}
errors.forEach { error ->
when (error) {
is ConfigException.IO -> logger.error(configFileNotFoundMessage(configFile))
is ConfigException.IO -> logger.error(configFileNotFoundMessage(configFile, error.cause))
else -> logger.error(error.message)
}
}
}
private fun configFileNotFoundMessage(configFile: Path): String {
private fun configFileNotFoundMessage(configFile: Path, cause: Throwable?): String {
return """
Unable to load the node config file from '$configFile'.
${cause?.message?.let { "Cause: $it" } ?: ""}
Try setting the --base-directory flag to change which directory the node
is looking in, or use the --config-file flag to specify it explicitly.