Skip to main content

Module err

Module err 

Source
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
  • c suffix: Prints an error message for an arbitrary error code
  • x suffix: 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 ERRNO followed by exiting with eval.
err_set_exit
Set or remove a callback to invoke before exiting on error.
err_set_file
Set global FILE sink to write errors and warnings.
errc
Print a user message then an error message for code before exiting with eval as a return.
errx
Print a user message then exits with eval as 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.