|
NAMEerr , verr ,
errc , verrc ,
errx , verrx ,
warn , vwarn ,
warnc , vwarnc ,
warnx , vwarnx ,
err_set_exit , err_set_file
—
formatted error messages
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <err.h>
void
void
void
void
void
void
void
void
void
void
void
void
void
void
DESCRIPTIONTheerr () and warn () family of
functions display a formatted error message on the standard error output, or
on another file specified using the err_set_file ()
function. In all cases, the last component of the program name, a colon
character, and a space are output. If the fmt argument
is not NULL, the
printf(3)-like
formatted error message is output. The output is terminated by a newline
character.
The In the case of the The The The EXAMPLESDisplay the current errno information string and exit:if ((p = malloc(size)) == NULL) err(EX_OSERR, NULL); if ((fd = open(file_name, O_RDONLY, 0)) == -1) err(EX_NOINPUT, "%s", file_name); Display an error message and exit: if (tm.tm_hour < START_TIME) errx(EX_DATAERR, "too early, wait until %s", start_time_string); Warn of an error: if ((fd = open(raw_device, O_RDONLY, 0)) == -1) warnx("%s: %s: trying the block device", raw_device, strerror(errno)); if ((fd = open(block_device, O_RDONLY, 0)) == -1) err(EX_OSFILE, "%s", block_device); Warn of an error without using the global variable errno: error = my_function(); /* returns a value from <errno.h> */ if (error != 0) warnc(error, "my_function"); SEE ALSOexit(3), fmtmsg(3), printf(3), strerror(3), sysexits(3)STANDARDSTheerr () and warn () families of
functions are BSD extensions. As such they should not
be used in truly portable code. Use strerror () or
similar functions instead.
HISTORYTheerr () and warn () functions
first appeared in 4.4BSD. The
err_set_exit () and
err_set_file () functions first appeared in
FreeBSD 2.1. The errc () and
warnc () functions first appeared in
FreeBSD 3.0.
Visit the GSP FreeBSD Man Page Interface. |