1
0

Replaced error pages with a new one.

This commit is contained in:
Alexander Andreev 2023-05-27 20:47:53 +04:00
parent d828c3adde
commit 7d9dc27411
Signed by: Arav
GPG Key ID: D22A817D95815393
2 changed files with 5 additions and 4 deletions

View File

@ -28,7 +28,7 @@ func (h *GuestbookApiHandlers) New(w http.ResponseWriter, r *http.Request) {
r.ParseForm() r.ParseForm()
if !inmemdb.Solve(captcha.ID(r.FormValue("captcha_id")), captcha.Answer(r.FormValue("captcha_answer"))) { if !inmemdb.Solve(captcha.ID(r.FormValue("captcha_id")), captcha.Answer(r.FormValue("captcha_answer"))) {
ForbiddenError("Wrong answer given.", "Here's your message:"+r.FormValue("message"), w) Error(w, http.StatusForbidden, "Wrong answer given.", "Here's your message:"+r.FormValue("message"))
return return
} }
@ -43,13 +43,13 @@ func (h *GuestbookApiHandlers) New(w http.ResponseWriter, r *http.Request) {
entry, err = justguestbook.NewEntry(r.FormValue("name"), message, entry, err = justguestbook.NewEntry(r.FormValue("name"), message,
r.FormValue("website"), r.FormValue("hide_website") != "") r.FormValue("website"), r.FormValue("hide_website") != "")
if err != nil { if err != nil {
InternalError(err.Error(), "Here's your message:"+r.FormValue("message"), w) Error(w, http.StatusInternalServerError, err.Error(), "Here's your message:"+r.FormValue("message"))
return return
} }
} }
if err = h.db.NewEntry(entry); err != nil { if err = h.db.NewEntry(entry); err != nil {
InternalError(err.Error(), "Here's your message:"+r.FormValue("message"), w) Error(w, http.StatusInternalServerError, err.Error(), "Here's your message:"+r.FormValue("message"))
return return
} }

View File

@ -49,7 +49,8 @@ func (h *MindflowApiHandlers) NewPost(w http.ResponseWriter, r *http.Request) {
} }
if err = h.db.NewPost(post); err != nil { if err = h.db.NewPost(post); err != nil {
InternalError(err.Error(), "Title: "+r.FormValue("title")+" | Body: "+r.FormValue("body"), w) msg := strings.Join([]string{"Title:", r.FormValue("title"), "| Body:", r.FormValue("body")}, " ")
Error(w, http.StatusInternalServerError, err.Error(), msg)
return return
} }