]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
hoist useful error messages
authorAlan T. DeKok <aland@freeradius.org>
Tue, 21 Mar 2023 15:25:45 +0000 (11:25 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 21 Mar 2023 15:41:27 +0000 (11:41 -0400)
src/lib/server/module_rlm.c
src/lib/unlang/compile.c

index b2c3289d90b82abd46cba1fb8a6bedaccada0322..00cae80e51bf46599b23c14da033e0ae2507c254 100644 (file)
@@ -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;
        }
index 2b6f6b92d8ff4b21bed2a47e994cb4eba8541d0f..b1b366749bb34857adbafb86639247fb5ecc69fb 100644 (file)
@@ -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;
        }