From: Alan T. DeKok Date: Tue, 21 Mar 2023 15:25:45 +0000 (-0400) Subject: hoist useful error messages X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d8af7834122ee090c3aa69c101e4a59cfeedfdc;p=thirdparty%2Ffreeradius-server.git hoist useful error messages --- diff --git a/src/lib/server/module_rlm.c b/src/lib/server/module_rlm.c index b2c3289d90b..00cae80e51b 100644 --- a/src/lib/server/module_rlm.c +++ b/src/lib/server/module_rlm.c @@ -595,7 +595,18 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, module * doesn't exist. */ p = strchr(name, '.'); - if (!p) return NULL; + if (!p) { + if (!mi) { + fr_strerror_printf("No such module '%s'", name); + + } else if (method_name2) { + fr_strerror_printf("Module '%s' does not have a '%s %s' method", name, method_name1, method_name2); + + } else { + fr_strerror_printf("Module '%s' does not have a '%s' method", name, method_name1); + } + return NULL; + } /* * The module name may have a '.' in it, AND it may have @@ -625,6 +636,7 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, module * No such module, we're done. */ if (!mi) { + fr_strerror_printf("Failed to find module '%s'", inst_name); talloc_free(inst_name); return NULL; } diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 2b6f6b92d8f..b1b366749bb 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -4832,21 +4832,7 @@ static unlang_t *compile_module(unlang_t *parent, unlang_compile_t *unlang_ctx, * component. */ if (!method) { - if (unlang_ctx->section_name1 && unlang_ctx->section_name2) { - cf_log_err(ci, "The \"%s\" module does not have a '%s %s' method.", - inst->module->name, - unlang_ctx->section_name1, unlang_ctx->section_name2); - - } else if (!unlang_ctx->section_name1) { - cf_log_err(ci, "The \"%s\" module cannot be called as '%s'.", - inst->module->name, realname); - - } else { - cf_log_err(ci, "The \"%s\" module does not have a '%s' method.", - inst->module->name, - unlang_ctx->section_name1); - } - + cf_log_err(ci, "Failed compiling %s - %s", inst->module->name, fr_strerror()); return NULL; } @@ -5150,9 +5136,7 @@ check_for_module: * named method. */ if (!unlang_ctx2.section_name1) { - cf_log_err(ci, "The '%s' module does not have a '%s %s' method.", - name, unlang_ctx->section_name1, - unlang_ctx->section_name2 ? unlang_ctx->section_name2 : ""); + cf_log_err(ci, "Failed compiling %s - %s", name, fr_strerror()); return NULL; }