Add proc table to error handler args

This commit is contained in:
Robert Miles 2018-10-20 15:50:00 -04:00
parent 13c7a065e6
commit dd2e8bafce
2 changed files with 5 additions and 4 deletions

View File

@ -10,8 +10,8 @@ A ComputerCraft service thingamagoocus.
- [X] Monitor processes
- [ ] Introspection
- [ ] See all running processes (IDs?)
- [ ] Error handlers
- [ ] Called with process table
- [X] Error handlers
- [X] Called with process table
- [X] Called with error
- [ ] Top-Level Coroutine Override
- [ ] No multishell

View File

@ -30,11 +30,12 @@ process.processes = {}
local nextID = 0
function process.spawn(fn,err)
if err==_G.error then err = nil end
local thisID = nextID
nextID = nextID + 1
local proc = {
co = coroutine.create(fn),
err = err or function(e) error(e) end,
err = err or function(e,p) error(e) end,
id = thisID,
status = process.status.ALIVE
}
@ -58,7 +59,7 @@ function process.tick(proc,event)
end
local ok,err = coroutine.resume(proc.co,table.unpack(event))
if not ok then
proc.err(err)
proc.err(err,proc)
proc.status = process.status.DEAD
else
proc.filter = err