Add sql no row handling
This commit is contained in:
parent
778ccdf8d2
commit
103ba4d6a2
6
main.go
6
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 != "" {
|
||||
|
|
Loading…
Reference in New Issue