From: Timo Sirainen Date: Thu, 20 Mar 2025 09:29:57 +0000 (+0200) Subject: config: Improve "Unknown section name" error with more details X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c7b7073a63c6cdac29b9226f483b8d939f1b42c7;p=thirdparty%2Fdovecot%2Fcore.git config: Improve "Unknown section name" error with more details --- diff --git a/src/config/config-parser.c b/src/config/config-parser.c index 78070b15d9..b97db6298c 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -2762,18 +2762,23 @@ void config_parser_apply_line(struct config_parser_context *ctx, const struct config_filter *cur_filter = &ctx->cur_section->filter_parser->filter; const char *key = line->key; + string_t *attempts = NULL; if (cur_filter->filter_name != NULL) { const char *filter_key = t_str_replace(cur_filter->filter_name, '/', '_'); const char *key2 = t_strdup_printf("%s_%s", filter_key, key); + attempts = t_str_new(64); if (config_key_can_autoprefix(ctx, key2)) key = key2; else { + str_printfa(attempts, " (%s", key2); filter_key = t_strcut(cur_filter->filter_name, '/'); key2 = t_strdup_printf("%s_%s", filter_key, key); if (config_key_can_autoprefix(ctx, key2)) key = key2; + else + str_printfa(attempts, ", %s", key2); } } else { i_assert(!cur_filter->filter_name_array); @@ -2791,8 +2796,11 @@ void config_parser_apply_line(struct config_parser_context *ctx, if (hash_table_lookup(ctx->all_keys, key) == NULL) { if (ctx->ignore_unknown) break; + if (attempts != NULL) + str_append(attempts, " not found either.)"); ctx->error = p_strdup_printf(ctx->pool, - "Unknown section name: %s", key); + "Unknown section name: %s%s", key, + attempts == NULL ? "" : str_c(attempts)); break; }