aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-10-15 15:57:28 +0000
committers-ol <s-ol@users.noreply.github.com>2019-10-15 15:57:28 +0000
commit74e6bb948fa84590b2c0b921868fa9abca6d41d2 (patch)
tree704bfd3b3b9870164a1fae0bbaa1099c4649b795 /build
parentadd xy-workshop (diff)
downloadmmm-74e6bb948fa84590b2c0b921868fa9abca6d41d2.tar.gz
mmm-74e6bb948fa84590b2c0b921868fa9abca6d41d2.zip
better error-handling / logging
Diffstat (limited to 'build')
-rw-r--r--build/server.moon11
1 files changed, 7 insertions, 4 deletions
diff --git a/build/server.moon b/build/server.moon
index 72b5ffd..aa7bf50 100644
--- a/build/server.moon
+++ b/build/server.moon
@@ -73,7 +73,9 @@ class Server
local store = web.WebStore({ verbose = true })
local root = fileder.Fileder(store, store:get_index(nil, -1))
- BROWSER = browser.Browser(root, path, facet, true)
+ local err_and_trace = function (msg) return debug.traceback(msg, 2) end
+ ok, BROWSER = xpcall(browser.Browser, err_and_trace, root, path, facet, true)
+ if not ok then error(BROWSER) end
end)
</script>"
else if not fileder\has_facet facet.name
@@ -88,6 +90,7 @@ class Server
else
501, "not implemented"
+ err_and_trace = (msg) -> debug.traceback msg, 2
stream: (sv, stream) =>
req = stream\get_headers!
method = req\get ':method'
@@ -102,10 +105,10 @@ class Server
type = type\match '%s*(.*)'
facet = Key facet, type
- ok, status, body = pcall @.handle, @, method, path, facet
+ ok, status, body = xpcall @.handle, err_and_trace, @, method, path, facet
if not ok
- warn status, body
- body = "Internal Server Error: #{status}"
+ warn "Error handling request (#{method} #{path} #{facet}):\n#{status}"
+ body = "Internal Server Error:\n#{status}"
status = 500
res = headers.new!