From a2e840f8fb1b30b66b5f230ad7980112e760f09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Erbsh=C3=A4u=C3=9Fer?= Date: Sun, 24 May 2026 09:22:29 +0200 Subject: [PATCH] add missing error handling in article creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Erbshäußer --- backend/blog.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/blog.go b/backend/blog.go index 6c86dd7..b0c3962 100644 --- a/backend/blog.go +++ b/backend/blog.go @@ -203,8 +203,6 @@ func (h *ApiHandler) ServeBlogPut(writer http.ResponseWriter, request *http.Requ _ = file.Close() }() - log.Println("creating new blog article ...") - id, commit, err := h.db.CreateBlogArticle() if err != nil { WriteError(writer, http.StatusInternalServerError, "failed to write database", err) @@ -219,6 +217,12 @@ func (h *ApiHandler) ServeBlogPut(writer http.ResponseWriter, request *http.Requ } err = commit(article) + if err != nil { + WriteError(writer, http.StatusInternalServerError, "failed to write database", err) + return + } + + log.Printf("created new blog article '%s'", article.Title) WriteResponse(writer, http.StatusOK, map[string]interface{}{ "id": id,