Overview
Coxpcall encapsulates the protected calls with a coroutine based loop,
so errors can be dealed without the usual pcall
/xpcall
issues with coroutines.
Using Coxpcall usually consists in simply loading the module and then
replacing Lua pcall
, xpcall
and coroutine.running
by copcall
, coxpcall
, and running
.
Coxpcall is free software and uses the same license as Lua 5.1 and 5.2.
Status
Current version is 1.14. It supports Lua 5.1 and Lua 5.2. Lua 5.2 was extended with the Coxpcall functionality and hence coxpcall is no longer required. The 5.2 compatibility by coxpcall means that it maintains backward compatibility while using the build in 5.2 implementation.
Download
Coxpcall can be downloaded from its GitHub page. You can also get Coxpcall using LuaRocks:
luarocks install coxpcall
History
- Coxpcall 1.15 [xx/xxx/xxxx]
- Added
running
function ascoroutine.running
replacement
- Added
- Coxpcall 1.14 [30/Jan/2013]
- Support for Lua 5.2
- Fixed bug, handling nil parameters, found by Thijs Schreijer
- Coxpcall 1.13 [19/May/2008]
- Fixed bug [#5275] (old tracker), found by Gary NG
- Coxpcall 1.12 [09/May/2008]
- Added stack traces
- Coxpcall 1.11 [22/Jan/2008]
- Moving Coxpcall to a standalone project since its now being used by more than only Xavante
- Refactoring and bug fixes by Thomas Harning Jr., Ignacio Burgueño and Fábio Mascarenhas
- Coxpcall 1.0 [18/Feb/2005]
- Coxpcall 1.0 until 1.11 was released as part of Xavante
Reference
Coxpcall offers three functions that reproduce the behaviour of
pcall
, xpcall
, and coroutine.running
:
coxpcall(f, err)
- Offers the same functionality as Lua
xpcall(f, err)
. copcall(f, ...)
- Offers the same functionality as Lua
pcall(f, ...)
. running([coro])
- Because
coxpcall
andcopcall
run the function to protect inside a new coroutine,coroutine.running()
will return an unexpected coroutine when used inside the protected function. If the coroutinecoro
was created by the coxpcall module, thenrunning(coro)
will return the original coroutine that created it. Ifcoro
is not provided, it will default to the currently running coroutine.
Credits
Coxpcall was designed and implemented by Roberto Ierusalimschy and André Carregal with the colaboration of Thomas Harning Jr., Ignacio Burgueño, Gary NG and Fábio Mascarenhas as part of the Kepler Project which holds its copyright.
Contact us
For more information please contact us. Comments are welcome!
You can also reach other Coxpcall developers and users on the Kepler Project mailing list.