summaryrefslogtreecommitdiff
path: root/worker.go
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-11-13 18:16:07 +0600
committerunwox <me@unwox.com>2024-11-13 20:47:08 +0600
commitab4a82dc0b267d48315fbb8c0bcf1d0939d7590e (patch)
treeff97e0ddbda2bf34af3fb3f5a0ff29a911c61736 /worker.go
parent7f62c1fd66ffeb7e46127e5972d814abb9299848 (diff)
improve stacktraces on errors
Diffstat (limited to 'worker.go')
-rw-r--r--worker.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/worker.go b/worker.go
index aa18b62..5ae69c2 100644
--- a/worker.go
+++ b/worker.go
@@ -89,10 +89,10 @@ func (w *Worker) Start(argv []string, module map[string]any) error {
w.lua.SetGlobal("luna")
err = w.lua.Require(argv[0])
-
if err != nil {
return err
}
+
w.started = true
return nil
}
@@ -123,6 +123,7 @@ func (w *Worker) Listen(queue chan *HTTPRequest) {
return
}
+ l.PushTracebackHandler()
l.PushFromRef(w.routes[r.route])
res := make(map[string]any)
res["method"] = r.request.Method
@@ -164,15 +165,14 @@ func (w *Worker) Listen(queue chan *HTTPRequest) {
return
}
- err = l.PCall(1, 3)
+ err = l.PCall(1, 3, -3)
if err != nil {
r.result <- &HTTPResponse{
Code: 500,
Headers: make(map[string]string),
Body: "server error",
}
- log.Println("could not process request:", err)
- // TODO: print lua stack as well?
+ log.Println("could not process request:\n" + err.Error())
return
}