From 405bc6d2d7efb9975a1a1e552a96ac7665d73404 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 4 Jun 2023 18:08:21 +0400 Subject: [PATCH] Moved misplaced error handler, added Error(...) to show what error happened. --- internal/http/web_handlers.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/http/web_handlers.go b/internal/http/web_handlers.go index 6368197..648e4e4 100644 --- a/internal/http/web_handlers.go +++ b/internal/http/web_handlers.go @@ -143,12 +143,13 @@ func (h *Handlers) Guestbook(w http.ResponseWriter, r *http.Request) { func (h *Handlers) GuestbookAdmin(w http.ResponseWriter, r *http.Request) { entriesCount, _ := h.guestbookDB.Count() entries, err := h.guestbookDB.Entries(1, entriesCount) + if err != nil { + Error(w, http.StatusInternalServerError, err.Error(), "cannot load gb") + return + } for _, entry := range entries { entry.Message = strings.ReplaceAll(entry.Message, "\\n", "\n") } - if err != nil { - return - } web.GuestbookAdmin("/ Guestbook Administration", h.guestbookOwner, entries, r, w) }