From 92948fab23820f351590c35fd9c026384362dfb5 Mon Sep 17 00:00:00 2001 From: Masaya Watanabe Date: Sat, 16 Oct 2021 16:57:59 +0900 Subject: [PATCH] fix missed errors (#417) Co-authored-by: Andrea Spacca --- server/handlers.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/handlers.go b/server/handlers.go index 807ca05..a31e29c 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -344,6 +344,11 @@ func (s *Server) postHandler(w http.ResponseWriter, r *http.Request) { } reader, err = os.Open(file.Name()) + if err != nil { + s.logger.Printf("%s", err.Error()) + http.Error(w, err.Error(), 500) + return + } } else { reader = bytes.NewReader(b.Bytes()) } @@ -493,6 +498,11 @@ func (s *Server) putHandler(w http.ResponseWriter, r *http.Request) { } reader, err = os.Open(file.Name()) + if err != nil { + s.logger.Printf("%s", err.Error()) + http.Error(w, err.Error(), 500) + return + } } else { reader = bytes.NewReader(b.Bytes()) }