This is handy when a module depends on another module at load time or
run time, and the config for that module needs to display a message
more helpful than the normal symbol-not-found or
optional-function-not-found or invalid-filter message.

The current kludge for generating an error message is to put it on a
single line in quotes like this:

<IfModule !mod_include.c>
"Tests won't work without mod_include!"
</IfModule>

yielding a message like

$ ./httpd -t
Syntax error on line 7 of /home/trawick/inst/23/conf/conf.d/fcgid.conf:
Invalid command 'Tests won't work without mod_include!', perhaps
misspelled or defined by a module not included in the server
configuration

(If the entire message isn't in quotes, the first token will be peeled
off and reported as the invalid command.)

With the Error directive:

<IfModule !mod_include.c>
Error mod_foo requires mod_include!  Use the LoadModule directive to
load mod_include.
</IfModule>


$ ./httpd -t
Syntax error on line 486 of /home/trawick/inst/23/conf/httpd.conf:
mod_foo requires mod_include!  Use the LoadModule directive to load mod_include.

Index: server/core.c
===================================================================
--- server/core.c       (revision 1032266)
+++ server/core.c       (working copy)
@@ -1092,6 +1092,11 @@
     return NULL;
 }

+static const char *set_error(cmd_parms *cmd, void *dummy, const char *arg)
+{
+    return arg;
+}
+
 #ifdef GPROF
 static const char *set_gprof_dir(cmd_parms *cmd, void *dummy, const char *arg)
 {
@@ -3432,6 +3437,8 @@
               "Define the existence of a variable.  Same as passing
-D to the command line."),
 AP_INIT_TAKE1("UnDefine", unset_define, NULL, RSRC_CONF,
               "Undefine the existence of a variable. Undo a Define."),
+AP_INIT_RAW_ARGS("Error", set_error, NULL, OR_ALL,
+                 "Generate error message from within configuration"),
 AP_INIT_RAW_ARGS("<If", ifsection, NULL, OR_ALL,
   "Container for directives to be conditionally applied"),

Reply via email to