NAME
|
waserror, poperror, nexterror, error, fmterror, silenterror – exception
handling for threaded programs |
SYNOPSIS
|
#include <u.h> #include <libc.h> #include <thread.h> #include <error.h> int waserror(void); void poperror(void) void nexterror(void); void error(char *err); void fmterror(char *fmt, ...); void silenterror(char *fmt, ...); |
DESCRIPTION
The functions in this library provide an aexception handling mechanism
modelled on that in the Plan 9 kernel. A construct such as
Waserror sets a point to which control returns if an exception occurs and returns zero. If the exception occurs, control transfers back to waserror and it then clears the point previously set and returns non–zero. Poperror clears the exception–return point previously set by waserror. Error, fmterror and silenterror all raise an error and they all set the error string. Fmterror and silenterror take a format string, while error just takes a simple string. Error and fmterror print the string on standard error as well. Silenterror does not.
Exception contexts bracketed by waserror and poperror can be nested.
When an exception has been handled in the innermost context, a
call to nexterror transfers it to the next larger context. |
EXAMPLES
Using exceptions to free dynamic memory:
|
DIAGNOSTICS
|
Waserror returns non–zero when an error was raised. |
SEE ALSO
|
worker(2) |
BUGS
|
The error stack is only 32 levels deep. |
AUTHOR
|
Sape Mullender |