Add sql no row handling

This commit is contained in:
Eliot Whalan 2016-06-19 11:57:35 +10:00
parent 0507cb0821
commit 326f707056
No known key found for this signature in database
GPG Key ID: C0A42175139840D6
1 changed files with 5 additions and 1 deletions

View File

@ -69,8 +69,12 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) {
db, err := sql.Open("sqlite3", "./database.db") db, err := sql.Open("sqlite3", "./database.db")
var s string var s string
err = db.QueryRow("select data from pastebin where id=?", param1).Scan(&s) err = db.QueryRow("select data from pastebin where id=?", param1).Scan(&s)
check(err)
db.Close() db.Close()
if err == sql.ErrNoRows {
io.WriteString(w, "Error invalid paste")
} else {
check(err)
}
if param1 != "" { if param1 != "" {
if param2 != "" { if param2 != "" {