lq-text: Error

/*VARARGS2*/ void Error (unsigned int Severity, CONST char *format, ...)

Purpose

Prints an error message, treating the given format argument as a printf-style format. The remaining arguments are optional, as for printf.

The error message is prepended by the command name (using the cmdname global variable, if set, or the value of the $CMDNAME environment variable otherwise), the program name (using the value of the global `progname', assigned by LQT_Init­From­Argv from argv[0] if not already set), and a string denoting the severity of the error, as determined by the Severity argument.

The Severity argument is a combination using bitwise or of the values defined in error.h, of which the most commonly used are as follows:

E_FATAL, which makes Error call exit and terminate the program;

E_WARN, which makes Error print warning: , and does not call exit;

E_BUG, used on an assertion failure or on detecting a severe problem that should be caught by testing; if any trace flags are set, E_BUG makes Error call abort to generate a core dump.

E_MEMORY; you should always include this if you think it might not be safe to call malloc, for example because the heap is corrupted or there is no more free memory.

E_SYS, which indicates a failed system or library call, and makes Error print the corresponding system error message using errno; be warned that on most systems, printf and other stdio functions may cause errno to be set even when there is no error, since they call isatty, which sets errno as a side-effect.

E_INTERNAL, which makes Error prepend the message with the string internal error: ;

E_MULTILINE, which should be used on all lines of a multi-line error message where Error is called multiple times; the last call to Error in the sequence must include the E_LASTLINE flag;

E_LASTLINE, which is only ever used on the last of a sequence of several successive calls to Error to build up a single message that spans several lines; in the case of E_FATAL errors, it is only on this call that Error will call exit, for example.

Bugs

An embedded newline in a string will cause a core dump on some systems. Error appends a newline automatically, so the safest thing to do is to omit the newline.