Actually handle errors correctly
This commit is contained in:
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user