From f649ea81728ac2ac6feff03ae277652fb0256c8f Mon Sep 17 00:00:00 2001 From: Blaster4385 Date: Sun, 2 Jun 2024 21:36:31 +0530 Subject: [PATCH] feat: improve error handling for handleGetFileInfo --- server/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/main.go b/server/main.go index 53d1c3d..8189750 100644 --- a/server/main.go +++ b/server/main.go @@ -191,7 +191,10 @@ func handleGetFileInfo(w http.ResponseWriter, r *http.Request) { } w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(fileInfo) + if err := json.NewEncoder(w).Encode(fileInfo); err != nil { + handleError(w, fmt.Errorf("error encoding response: %v", err), http.StatusInternalServerError) + return + } } func storeFileInDB(ctx context.Context, id, fileName string, encryptedData []byte) error {