diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2013-05-04 21:26:49 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2013-05-04 21:26:49 (GMT) |
| commit | 66e21ce0498f623ccffcee95b1fdcbc218464caa (patch) | |
| tree | 83de913847ce0b1808c46a1bdedb1c4c6c66296d /src/socket/except.h | |
| parent | 3799d5ed86e7b508b39544cad3b3346655c804f1 (diff) | |
| parent | e7b29ab9b5e037a8896c62f0473cae8d353d5114 (diff) | |
| download | powder-66e21ce0498f623ccffcee95b1fdcbc218464caa.zip powder-66e21ce0498f623ccffcee95b1fdcbc218464caa.tar.gz | |
Merge pull request #131 from mniip/lua
builtin luasocket
Diffstat (limited to 'src/socket/except.h')
| -rw-r--r-- | src/socket/except.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/socket/except.h b/src/socket/except.h new file mode 100644 index 0000000..81efb29 --- /dev/null +++ b/src/socket/except.h @@ -0,0 +1,35 @@ +#ifndef EXCEPT_H +#define EXCEPT_H +/*=========================================================================*\ +* Exception control +* LuaSocket toolkit (but completely independent from other modules) +* +* This provides support for simple exceptions in Lua. During the +* development of the HTTP/FTP/SMTP support, it became aparent that +* error checking was taking a substantial amount of the coding. These +* function greatly simplify the task of checking errors. +* +* The main idea is that functions should return nil as its first return +* value when it finds an error, and return an error message (or value) +* following nil. In case of success, as long as the first value is not nil, +* the other values don't matter. +* +* The idea is to nest function calls with the "try" function. This function +* checks the first value, and calls "error" on the second if the first is +* nil. Otherwise, it returns all values it received. +* +* The protect function returns a new function that behaves exactly like the +* function it receives, but the new function doesn't throw exceptions: it +* returns nil followed by the error message instead. +* +* With these two function, it's easy to write functions that throw +* exceptions on error, but that don't interrupt the user script. +* +* RCS ID: $Id: except.h,v 1.2 2005/09/29 06:11:41 diego Exp $ +\*=========================================================================*/ + +#include "lua.h" + +int except_open(lua_State *L); + +#endif |
