Expand description
err.h implementation.
See https://man.freebsd.org/cgi/man.cgi?err
err.h is a BSD extension to the C library which provides functions for printing formatted
errors. Errors are printed to stdio::stderr by default or to a file set by
err_set_file. This family of functions is non-portable, but it is also supported by glibc
and musl.
The functions come in sets of three. Each of them print the program binary name (the last path
segment of argv[0]) and an optional user message along with these differences:
- No suffix: Prints an error message for ERRNO based on
strerror csuffix: Prints an error message for an arbitrary error codexsuffix: Does not print an error code
For example, err does not have a suffix so it would print the program name, the user message,
and an error string for ERRNO. errc would operate in the same way except the functions takes
an error code for which to print an error string.
Functions§
- err⚠
- Print a user message then an error message for
ERRNOfollowed by exiting witheval. - err_
set_ ⚠exit - Set or remove a callback to invoke before exiting on error.
- err_
set_ ⚠file - Set global
FILEsink to write errors and warnings. - errc⚠
- Print a user message then an error message for
codebefore exiting withevalas a return. - errx⚠
- Print a user message then exits with
evalas a return. - verr⚠
- See
err. - verrc⚠
- See
errc. - verrx⚠
- See
errx; - vwarn⚠
- See
warn. - vwarnc⚠
- See
warnc. - vwarnx⚠
- See
warnx. - warn⚠
- Print a user message and then an error message for
ERRNO. - warnc⚠
- Print a user message then an error message for
code. - warnx⚠
- Print a user message as a warning.