beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luasocket / src / except.h
blob1e7a2455e70889f7406506c6a541ec31315f2147
1 #ifndef EXCEPT_H
2 #define EXCEPT_H
3 /*=========================================================================*\
4 * Exception control
5 * LuaSocket toolkit (but completely independent from other modules)
7 * This provides support for simple exceptions in Lua. During the
8 * development of the HTTP/FTP/SMTP support, it became aparent that
9 * error checking was taking a substantial amount of the coding. These
10 * function greatly simplify the task of checking errors.
12 * The main idea is that functions should return nil as its first return
13 * value when it finds an error, and return an error message (or value)
14 * following nil. In case of success, as long as the first value is not nil,
15 * the other values don't matter.
17 * The idea is to nest function calls with the "try" function. This function
18 * checks the first value, and calls "error" on the second if the first is
19 * nil. Otherwise, it returns all values it received.
21 * The protect function returns a new function that behaves exactly like the
22 * function it receives, but the new function doesn't throw exceptions: it
23 * returns nil followed by the error message instead.
25 * With these two function, it's easy to write functions that throw
26 * exceptions on error, but that don't interrupt the user script.
27 \*=========================================================================*/
29 #include "lua.h"
31 int except_open(lua_State *L);
33 #endif