Pretty error message when post does not have an author

Replace the basic error message when a post does not have an author
with a nice looking error message page.
This commit is contained in:
Robin Malley 2022-01-23 18:19:20 +00:00
parent 16054156a1
commit 9667aa1c3e
1 changed files with 10 additions and 1 deletions

View File

@ -41,7 +41,16 @@ local function edit_post(req)
local err = util.do_sql(stmnt_author_of)
if err ~= sql.ROW then
stmnt_author_of:reset()
error("No author found for story:" .. storyid)
local msg = string.format("No author found for story: %d", storyid)
log(LOG_ERR,msg)
local response = pages.error{
errcode = 404,
errcodemsg = "Not Found",
explanation = msg,
should_traceback = true,
}
http_response(req,404,response)
return
end
local data = stmnt_author_of:get_values()
stmnt_author_of:reset()