From 103ba4d6a206f0d92d44654e87f64fa73241d270 Mon Sep 17 00:00:00 2001 From: Eliot Whalan Date: Sun, 19 Jun 2016 11:57:35 +1000 Subject: [PATCH] Add sql no row handling --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 85e6430..815976e 100644 --- a/main.go +++ b/main.go @@ -69,8 +69,12 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) { db, err := sql.Open("sqlite3", "./database.db") var s string err = db.QueryRow("select data from pastebin where id=?", param1).Scan(&s) - check(err) db.Close() + if err == sql.ErrNoRows { + io.WriteString(w, "Error invalid paste") + } else { + check(err) + } if param1 != "" { if param2 != "" {