Sun Java System Directory Server Enterprise Edition 6.2 Developer's Guide

Fatal Error Messages

For fatal errors, use slapi_log_error_ex(). In many cases, you might return -1 after you log the message to indicate to Directory Server that a serious problem has occurred.

Example 4–5 Logging a Fatal Error Message

#include "slapi-plugin.h"
#include "example-com-error-ids.h" /* unique
                                      error IDs file       */
foobar(Slapi_PBlock * pb)
    char * error_cause;
    int    apocalypse = 1;         /* Expect the worst.    */

    /* ... */

    if (apocalypse) {              /* Server to crash soon */
            EXCOM_SERVER_MORIBUND, /* Unique error ID      */
            " foobar in baz plug-in",
            "cannot write to file system: %s\n",
        return -1;
    return 0;

In this example, foobar() logs an error as Directory Server is about to crash.

Tip –

If the plug-ins are internationalized, use macros, not literal strings, for the last two arguments to slapi_log_*_ex() functions.