mirror of https://github.com/Hilbis/Hilbish
fix: handle errors in goro and timeout callbacks
parent
83ca8066e6
commit
5175367b35
20
api.go
20
api.go
|
@ -274,11 +274,13 @@ func hlgoro(L *lua.LState) int {
|
||||||
|
|
||||||
// call fn
|
// call fn
|
||||||
go func() {
|
go func() {
|
||||||
L.CallByParam(lua.P{
|
if err := L.CallByParam(lua.P{
|
||||||
Fn: fn,
|
Fn: fn,
|
||||||
NRet: 0,
|
NRet: 0,
|
||||||
Protect: true,
|
Protect: true,
|
||||||
}, args...)
|
}, args...); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, "Error in goro function:\n\n", err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
@ -295,11 +297,13 @@ func hltimeout(L *lua.LState) int {
|
||||||
timeout := time.Duration(ms) * time.Millisecond
|
timeout := time.Duration(ms) * time.Millisecond
|
||||||
time.Sleep(timeout)
|
time.Sleep(timeout)
|
||||||
|
|
||||||
L.CallByParam(lua.P{
|
if err := L.CallByParam(lua.P{
|
||||||
Fn: cb,
|
Fn: cb,
|
||||||
NRet: 0,
|
NRet: 0,
|
||||||
Protect: true,
|
Protect: true,
|
||||||
})
|
}); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, "Error in goro function:\n\n", err)
|
||||||
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue