mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
Update comment in except.h
This commit is contained in:
parent
7c1df8a7cd
commit
7cab8a5006
23
src/except.h
23
src/except.h
@ -9,21 +9,26 @@
|
|||||||
* error checking was taking a substantial amount of the coding. These
|
* error checking was taking a substantial amount of the coding. These
|
||||||
* function greatly simplify the task of checking errors.
|
* function greatly simplify the task of checking errors.
|
||||||
*
|
*
|
||||||
* The main idea is that functions should return nil as its first return
|
* The main idea is that functions should return nil as their first return
|
||||||
* value when it finds an error, and return an error message (or value)
|
* values when they find an error, and return an error message (or value)
|
||||||
* following nil. In case of success, as long as the first value is not nil,
|
* following nil. In case of success, as long as the first value is not nil,
|
||||||
* the other values don't matter.
|
* the other values don't matter.
|
||||||
*
|
*
|
||||||
* The idea is to nest function calls with the "try" function. This function
|
* 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
|
* checks the first value, and, if it's falsy, wraps the second value in a
|
||||||
* nil. Otherwise, it returns all values it received.
|
* table with metatable and calls "error" on it. Otherwise, it returns all
|
||||||
|
* values it received. Basically, it works like the Lua "assert" function,
|
||||||
|
* but it creates errors targeted specifically at "protect".
|
||||||
*
|
*
|
||||||
* The protect function returns a new function that behaves exactly like the
|
* The "newtry" function is a factory for "try" functions that call a
|
||||||
* function it receives, but the new function doesn't throw exceptions: it
|
* finalizer in protected mode before calling "error".
|
||||||
* returns nil followed by the error message instead.
|
|
||||||
*
|
*
|
||||||
* With these two function, it's easy to write functions that throw
|
* The "protect" function returns a new function that behaves exactly like
|
||||||
* exceptions on error, but that don't interrupt the user script.
|
* the function it receives, but the new function catches exceptions thrown
|
||||||
|
* by "try" functions and returns nil followed by the error message instead.
|
||||||
|
*
|
||||||
|
* With these three functions, it's easy to write functions that throw
|
||||||
|
* exceptions on error, but that don't interrupt the user script.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user