flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit f63edd7303f49c0919c3009b93c93e6009f4e873
parent 461036c5579c4f9e23c45e8d15499eea089b4f1c
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Mon,  1 Feb 2021 18:20:18 -0800

Improve error handling on no file found

I think I was defer-ing too early

Diffstat:
Mhttp.go | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/http.go b/http.go @@ -180,13 +180,13 @@ func uploadFilesHandler(w http.ResponseWriter, r *http.Request) { } r.ParseMultipartForm(10 << 6) // why does this not work file, fileHeader, err := r.FormFile("file") - fileName := filepath.Clean(fileHeader.Filename) - defer file.Close() if err != nil { log.Println(err) - renderError(w, err.Error(), http.StatusBadRequest) + renderError(w, "No file selected. Please go back and select a file.", http.StatusBadRequest) return } + fileName := filepath.Clean(fileHeader.Filename) + defer file.Close() dest, _ := ioutil.ReadAll(file) err = checkIfValidFile(user.Username, fileName, dest) if err != nil {