diff options
| author | unwox <me@unwox.com> | 2024-11-13 18:16:07 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-11-13 20:47:08 +0600 |
| commit | ab4a82dc0b267d48315fbb8c0bcf1d0939d7590e (patch) | |
| tree | ff97e0ddbda2bf34af3fb3f5a0ff29a911c61736 /worker.go | |
| parent | 7f62c1fd66ffeb7e46127e5972d814abb9299848 (diff) | |
improve stacktraces on errors
Diffstat (limited to 'worker.go')
| -rw-r--r-- | worker.go | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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 } |
