From 311454d05db929ce835f3ad9606e19508ef07c67 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Sat, 31 Dec 2022 04:53:09 +0100 Subject: [PATCH] Fixed some typos / improved api messages --- internal/articles/handlers.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/articles/handlers.go b/internal/articles/handlers.go index f02d96c..0fa4e0e 100644 --- a/internal/articles/handlers.go +++ b/internal/articles/handlers.go @@ -54,7 +54,7 @@ func AddArticleHandler(c *gin.Context) { err = database.PushDocument(articlesLocation, document) if err != nil { - api.SendBadRequest(c, fmt.Sprintf(`Could not insert document into DB: %v`, err.Error())) + api.SendBadRequest(c, fmt.Sprintf(`Could not insert document(s) into DB: %v`, err.Error())) return } @@ -66,12 +66,12 @@ func DeleteArticleHandler(c *gin.Context) { deleteCount, err := database.DeleteDocument(articlesLocation, gin.H{"id_name": id}) if err != nil { - api.SendBadRequest(c, "Could not delete document into DB.") + api.SendBadRequest(c, fmt.Sprintf(`Could not delete document(s) from DB: %v`, err.Error())) return } if deleteCount != 0 { - api.SendOk(c, fmt.Sprintf("%d articles were successfully deleted!", deleteCount)) + api.SendOk(c, fmt.Sprintf("%d article(s) was/were successfully deleted!", deleteCount)) } else { api.SendOk(c, "No articles were deleted.") } @@ -86,12 +86,12 @@ func EditArticleHandler(c *gin.Context) { editCount, err := database.EditDocument(articlesLocation, articleUpdate) if err != nil { - api.SendBadRequest(c, err.Error()) + api.SendBadRequest(c, fmt.Sprintf(`Could not edit document(s) from DB: %v`, err.Error())) return } if editCount != 0 { - api.SendOk(c, fmt.Sprintf("%d articles were successfully edited!", editCount)) + api.SendOk(c, fmt.Sprintf("%d article(s) was/were successfully edited!", editCount)) } else { api.SendOk(c, "No articles were edited.") }