From 1c83f69879e934c1431b70f3f933baccbc6fdd24 Mon Sep 17 00:00:00 2001 From: Eliot Whalan Date: Sat, 11 Jun 2016 12:22:22 +1000 Subject: [PATCH] Add proper error handling --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 8208be1..ab07460 100644 --- a/main.go +++ b/main.go @@ -66,7 +66,8 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) { io.WriteString(w, text) } case "POST": - buf, _ := ioutil.ReadAll(r.Body) + buf, err := ioutil.ReadAll(r.Body) + check(err) io.WriteString(w, address+save(buf)+"\n") case "DELETE": // Remove the record. @@ -75,6 +76,7 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) { func main() { http.HandleFunc("/", pasteHandler) - http.ListenAndServe(":8080", nil) + err := http.ListenAndServe(":8080", nil) + check(err) }