[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [ANN] Propagate 1.0 - Error/status propagation in Lua
- From: "Soni L." <fakedme@...>
- Date: Thu, 23 Feb 2017 19:44:02 -0300
Propagate is a module for cleanly propagating error/status codes to the
caller.
Repo: https://bitbucket.org/TeamSoni/propagate
Features:
- Depends on APow[1]. (Seems like I've been doing a lot of stuff that
depends on APow, eh?)
- Coroutine tricks.
- Incompatible with Typecheck[2] because I'm a n00b.
Examples:
On a Linux system, the following:
- - -
local propagate = require "propagate"
local f = propagate.enable ^ function(x)
propagate.propagate(x:write("hello\n"))
propagate.propagate(x:close())
return x
end
print(1, f(io.open("/dev/null", 'w')))
print(2, f(io.open("/dev/null")))
print(3, f(io.stdout))
- - -
outputs:
- - -
1 file (closed)
2 nil Bad file descriptor 9
hello
3 nil cannot close standard file
- - -
[1] http://marc.info/?l=lua-l&m=148745285529221&w=2
[2] http://marc.info/?l=lua-l&m=148755896416687&w=2
--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.