Actually handle errors correctly
This commit is contained in:
parent
9f774cf169
commit
0462da1240
3
lib.lua
3
lib.lua
@ -119,7 +119,8 @@ local function serve(fn, node_type)
|
|||||||
|
|
||||||
local ok, result = pcall(fn, message.request)
|
local ok, result = pcall(fn, message.request)
|
||||||
if not ok then
|
if not ok then
|
||||||
response = errors.make(errors.INTERNAL, result)
|
if type(result) ~= "table" or not result.error then response = errors.make(errors.INTERNAL, result)
|
||||||
|
else response = result end
|
||||||
print("Error:", textutils.serialise(result)) -- show error
|
print("Error:", textutils.serialise(result)) -- show error
|
||||||
else
|
else
|
||||||
local end_time = os.clock()
|
local end_time = os.clock()
|
||||||
|
Loading…
Reference in New Issue
Block a user