config/File: print warning about deprecated options

This commit is contained in:
Max Kellermann 2018-09-23 15:43:38 +02:00
parent dcac32a6c4
commit a82d864c91
2 changed files with 10 additions and 1 deletions

View File

@ -116,6 +116,11 @@ ReadConfigBlock(ConfigData &config_data, BufferedReader &reader,
const unsigned i = unsigned(o);
const ConfigTemplate &option = config_block_templates[i];
if (option.deprecated)
FormatWarning(config_file_domain,
"config parameter \"%s\" on line %u is deprecated",
name, reader.GetLineNumber());
if (!option.repeatable)
if (const auto *block = config_data.GetBlock(o))
throw FormatRuntimeError("config parameter \"%s\" is first defined "
@ -143,6 +148,11 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
const unsigned i = unsigned(o);
const ConfigTemplate &option = config_param_templates[i];
if (option.deprecated)
FormatWarning(config_file_domain,
"config parameter \"%s\" on line %u is deprecated",
name, reader.GetLineNumber());
if (!option.repeatable)
if (const auto *param = config_data.GetParam(o))
throw FormatRuntimeError("config parameter \"%s\" is first defined "

View File

@ -24,7 +24,6 @@ struct ConfigTemplate {
const char *const name;
const bool repeatable;
// TODO: print warning when a deprecated option is used
const bool deprecated;
constexpr ConfigTemplate(const char *_name,