From 9667aa1c3e32b7bbd069a83a71ebc887463af96d Mon Sep 17 00:00:00 2001 From: Robin Malley Date: Sun, 23 Jan 2022 18:19:20 +0000 Subject: [PATCH] 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. --- src/lua/endpoints/edit_post.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lua/endpoints/edit_post.lua b/src/lua/endpoints/edit_post.lua index 8df2fec..b3505ee 100644 --- a/src/lua/endpoints/edit_post.lua +++ b/src/lua/endpoints/edit_post.lua @@ -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()