From 887c3a800d4a8b0db3cc156de51ac5c33fd22e23 Mon Sep 17 00:00:00 2001 From: Nils <57401795+NilsArnlund@users.noreply.github.com> Date: Wed, 2 Oct 2024 09:50:43 +0200 Subject: [PATCH] [GH-28355] Fixed errcheck issues in server/channels/api4/channel_category.go (#28357) --- server/.golangci.yml | 1 - server/channels/api4/channel_category.go | 25 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/server/.golangci.yml b/server/.golangci.yml index 1fcd068664..af1db56fcf 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -63,7 +63,6 @@ issues: channels/api4/bot_test.go|\ channels/api4/brand.go|\ channels/api4/channel.go|\ - channels/api4/channel_category.go|\ channels/api4/channel_test.go|\ channels/api4/cloud.go|\ channels/api4/cloud_test.go|\ diff --git a/server/channels/api4/channel_category.go b/server/channels/api4/channel_category.go index 56b17de398..c6f07e1091 100644 --- a/server/channels/api4/channel_category.go +++ b/server/channels/api4/channel_category.go @@ -35,7 +35,9 @@ func getCategoriesForTeamForUser(c *Context, w http.ResponseWriter, r *http.Requ return } - w.Write(categoriesJSON) + if _, err := w.Write(categoriesJSON); err != nil { + c.Logger.Warn("Error while writing response", mlog.Err(err)) + } } func createCategoryForTeamForUser(c *Context, w http.ResponseWriter, r *http.Request) { @@ -78,7 +80,9 @@ func createCategoryForTeamForUser(c *Context, w http.ResponseWriter, r *http.Req auditRec.Success() - w.Write(categoryJSON) + if _, err := w.Write(categoryJSON); err != nil { + c.Logger.Warn("Error while writing response", mlog.Err(err)) + } } func getCategoryOrderForTeamForUser(c *Context, w http.ResponseWriter, r *http.Request) { @@ -138,7 +142,10 @@ func updateCategoryOrderForTeamForUser(c *Context, w http.ResponseWriter, r *htt } auditRec.Success() - w.Write([]byte(model.ArrayToJSON(categoryOrder))) + + if _, err := w.Write([]byte(model.ArrayToJSON(categoryOrder))); err != nil { + c.Logger.Warn("Error while writing response", mlog.Err(err)) + } } func getCategoryForTeamForUser(c *Context, w http.ResponseWriter, r *http.Request) { @@ -164,7 +171,9 @@ func getCategoryForTeamForUser(c *Context, w http.ResponseWriter, r *http.Reques return } - w.Write(categoriesJSON) + if _, err := w.Write(categoriesJSON); err != nil { + c.Logger.Warn("Error while writing response", mlog.Err(err)) + } } func updateCategoriesForTeamForUser(c *Context, w http.ResponseWriter, r *http.Request) { @@ -213,7 +222,9 @@ func updateCategoriesForTeamForUser(c *Context, w http.ResponseWriter, r *http.R } auditRec.Success() - w.Write(categoriesJSON) + if _, err := w.Write(categoriesJSON); err != nil { + c.Logger.Warn("Error while writing response", mlog.Err(err)) + } } func validateSidebarCategory(c *Context, teamId, userId string, category *model.SidebarCategoryWithChannels) *model.AppError { @@ -309,7 +320,9 @@ func updateCategoryForTeamForUser(c *Context, w http.ResponseWriter, r *http.Req } auditRec.Success() - w.Write(categoryJSON) + if _, err := w.Write(categoryJSON); err != nil { + c.Logger.Warn("Error while writing response", mlog.Err(err)) + } } func deleteCategoryForTeamForUser(c *Context, w http.ResponseWriter, r *http.Request) {