err

err#

Simple error reporting library.

This library is modelled after the BSD error reporting family of functions with a few extensions. These functions mostly follows the documented behaviour in the unix err(3) man page, with the major exception that err() and errx() does not call exit() (unless the environment variable ERR_ABORT is set to “exit”).

Used environment variables

  • ERR_STREAM: Error stream to write messages to.

    • empty : do not write anything

    • ”stderr” | unset : write to stderr

    • ”stdout” : write to stdout

    • otherwise : open the given file and append to it

  • ERR_ABORT: Whether errors should should return normally, exit or about.

    • ”0” | “normal” | unset : return normally

    • ”1” | “exit” : exit

    • ”2” | “abort” | empty : abort

    • otherwise : return normally

  • ERR_WARN: Whether warnings should be ignored or turned into errors.

    • ”0” | “normal” | unset : report normally

    • ”1” | “ignore” : ignore

    • ”2” | “error” : turn into error

    • otherwise : report normally

  • ERR_DEBUG: Wheter debugging information (source file, line number and function name) should be included in the error message.

    • ”0” | unset | empty : no debugging info

    • ”1” | “debug” : print file and line number

    • ”2” | “full” : print file, line number and function

    • otherwise : no debugging info

  • ERR_OVERRIDE: How to handle error messages when there already is a message in the error message buffer. Note that these options will only affect the error message, not the error value.

    • unset | empty : append new error message to the old one

    • ”0” | “append” : append new error message

    • ”1” | “warn-old” : overwrite old error message and write warning

    • ”2” | “warn-new” : ignore new error message and write warning

    • ”3” | “old” : overwrite old error message

    • ”4” | “ignore-new” : ignore new error message

    • otherwise : append new error message to the old one

  • ERR_COLOR: Whether to write error messages colour-coded.

    • unset | “auto” : colour-coded only if connected to a terminal

    • ”no” | “never” : not colour-coded

    • ”yes” | “always” : colour-coded

Defines

ERR_MSGSIZE#

Buffer size for error messages.

err_default_stream#

Default error stream (checks the ERR_STREAM environment variable)