1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00

enhance error handling

This commit is contained in:
lxsang 2020-09-22 16:51:01 +02:00
parent 5dd6da0b29
commit c4a3c425a8

View File

@ -25,6 +25,10 @@ function CommentController:index(...)
result("") result("")
return false return false
end end
if not REQUEST.json then
fail("Invalid request")
return false
end
local rq = (JSON.decodeString(REQUEST.json)) local rq = (JSON.decodeString(REQUEST.json))
if (rq) then if (rq) then
local pages, order = self.pages:find({exp = {["="] = {uri = rq.page}}}) local pages, order = self.pages:find({exp = {["="] = {uri = rq.page}}})
@ -82,6 +86,10 @@ function CommentController:post(...)
result("") result("")
return false return false
end end
if not REQUEST.json then
fail("Invalid request")
return false
end
local rq = (JSON.decodeString(REQUEST.json)) local rq = (JSON.decodeString(REQUEST.json))
if rq then if rq then
local pages, order = self.pages:find({exp = {["="] = rq.page}}) local pages, order = self.pages:find({exp = {["="] = rq.page}})
@ -136,6 +144,10 @@ function CommentController:preview(...)
result("") result("")
return false return false
end end
if not REQUEST.json then
fail("Invalid request")
return false
end
local rq = (JSON.decodeString(REQUEST.json)) local rq = (JSON.decodeString(REQUEST.json))
if (rq and rq.data) then if (rq and rq.data) then
result(process_md(rq.data)) result(process_md(rq.data))