ERROR(3)
π ERROR(3) π
okay so bestie, this is the ERROR(3) page from the Library Functions Manual, and itβs literally the error and debug trace message formatter. group-chat energy: ON. π«Ά
β¨ NAME β¨
errorβ error and debug trace message formatter. thatβs the whole name section, icon behavior only. π
π SYNOPSIS π
#include <error.h>
Error_info_t error_info;
void error(int level, ...);
void errorv(const char* library, int level, va_alist args);
void liberror(const char* library, int level, ...);
#include <debug.h>
debug(statement)
message((int level, ...))
libmessage((const char* library, int level, ...))
πΈ DESCRIPTION πΈ
okay so error is the error and debug trace message formatter, and level is the severity level. messages with level < error_info.trace are suppressed. error_info.trace is initially 0. the remaining arguments are passed on to printf. a newline is appended to the message text, so none should appear in the printf format. if error_info.id is not 0, then messages with level > 0 are prefixed by error_info.id:. yes, colon included, we donβt make the rules. π
before the message text is output to standard error, it is passed to the function char* ERROR_translate(const char* text, int flag). by default ERROR_translate returns the text argument, but on some systems it may do language translation via lookup on the original source text. (error calls ERROR_translate with a 0 flag argument). cute.
level may be one of:
<0β negative values are for debug tracing. debug messages are prefixed withdebuglevel. iferrno != error_info.last_errno, thenerror_info.last_errnois set toerrnoand the error text forerrnois appended to the message.ERROR_INFO[0]β information only; no prefixes are added to the message.ERROR_WARNING[1]βwarning:is added aftererror_info.idanderror_info.warningsis incremented.ERROR_ERROR[2]β (soft error)error_info.errorsis incremented.>= ERROR_FATAL[3]β (hard error)error_info.errorsis incremented andexit(level-2)is called after the message is emitted.ERROR_PANIC[77]β (unrecoverable internal error)panic:is added aftererror_info.id.
the following may be inclusive-or'd into level for alternate behavior:
ERROR_SYSTEMβ the error text forerrnois appended to the message.ERROR_OUTPUTβ the next argument is the file descriptor where the error message should be emitted.ERROR_SOURCEβ the next two arguments are a file name and line number that are added to the message aftererror_info.id.ERROR_USAGEβ a usage message is emitted.ERROR_PROMPTβ the trailing newline is suppressed.ERROR_NOIDβ theerror_info.idprefix is suppressed.ERROR_LIBRARYβ the message is from a library routine.
π ENVIRONMENT π
the elements of the global struct error_info control error output and actions. parts of error_info can be initialized from the ERROR_OPTIONS environment variable. ERROR_OPTIONS contains space separated name[=value] options, described below.
int coreβ iferror_info.core != 0, thenlevel >= error_info.coregenerates a core dump. initialized byERROR_OPTIONS="core=level"wherelevelcan be a number or one oferror,fatal, orpanic.error_info.coreis a handy way to get a stack trace at the exact point of error.int error_info.traceβ iferror_info.trace != 0andlevel < error_info.trace, then the error message text is suppressed.exit()may still be called if appropriate forlevel. initialized byERROR_OPTIONS="trace=level"whereerror_info.traceis set to the negative oflevel.
library error messages, suppressed by default, are enabled by ERROR_OPTIONS="library". the system errno message text can be forced for each message by ERROR_OPTIONS="system".
π¦ EXTENDED DESCRIPTION π¦
<debug.h> provides debugging message macros when DEBUG or _TRACE_ are defined (_TRACE_ is defined by makerules when CCFLAGS contains -g). all of the macros expand to nothing when both DEBUG and _TRACE_ are not defined. otherwise debug expands its arg and libmessage and message call liberror and error respectively if error_info.trace<0.
π¨ notice:libmessageandmessageare macro hacks that require double parentheses((...))around the arguments.
β¨ EXAMPLE β¨
to enable debugging message level -3, library messages, and system errno text for all commands:
export ERROR_OPTIONS="trace=3 library system"
xoxo, bestie π β that was ERROR(3) from the Library Functions Manual. the footer didnβt print a version or date, so no cap, weβre not inventing one. stay slay. π
π¦ where this page comes from
- opensuse-leap 16.0: ksh-devel 93vu-bp160.1.33 Β· CPL-1.0
- opensuse-leap 16.0: ksh-devel 93vu-bp160.1.33 Β· CPL-1.0
- opensuse-leap 16.0: ksh-devel 93vu-bp160.1.33 Β· CPL-1.0
- opensuse-leap 16.0: ksh-devel 93vu-bp160.1.33 Β· CPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms