every database exec must have error checking

This commit is contained in:
Ted Unangst 2019-08-16 00:15:55 -04:00
parent 5b309bb846
commit fbe47a0895
3 changed files with 31 additions and 9 deletions

View File

@ -230,13 +230,19 @@ func savexonk(user *WhatAbout, x *Honk) {
log.Printf("eradicating %s by %s", x.XID, x.Honker)
xonk := getxonk(user.ID, x.XID)
if xonk != nil {
stmtZonkDonks.Exec(xonk.ID)
_, err := stmtZonkIt.Exec(user.ID, x.XID)
_, err := stmtZonkDonks.Exec(xonk.ID)
if err != nil {
log.Printf("error eradicating: %s", err)
}
_, err = stmtZonkIt.Exec(user.ID, x.XID)
if err != nil {
log.Printf("error eradicating: %s", err)
}
}
stmtSaveZonker.Exec(user.ID, x.XID, "zonk")
_, err := stmtSaveZonker.Exec(user.ID, x.XID, "zonk")
if err != nil {
log.Printf("error eradicating: %s", err)
}
return
}
log.Printf("saving xonk: %s", x.XID)
@ -966,7 +972,10 @@ func gofish(name string) string {
rel, _ := l.GetString("rel")
t, _ := l.GetString("type")
if rel == "self" && friendorfoe(t) {
stmtSaveXonker.Exec(name, href, "fishname")
_, err := stmtSaveXonker.Exec(name, href, "fishname")
if err != nil {
log.Printf("error saving fishname: %s", err)
}
handlock.Lock()
handfull[name] = href
handlock.Unlock()

View File

@ -50,7 +50,10 @@ func sayitagain(goarounds int, username string, rcpt string, msg []byte) {
}
drift += time.Duration(notrand.Int63n(int64(drift / 10)))
when := time.Now().UTC().Add(drift)
stmtAddDoover.Exec(when.Format(dbtimeformat), goarounds, username, rcpt, msg)
_, err := stmtAddDoover.Exec(when.Format(dbtimeformat), goarounds, username, rcpt, msg)
if err != nil {
log.Printf("error saving doover: %s", err)
}
select {
case pokechan <- 0:
default:
@ -150,7 +153,11 @@ func redeliverator() {
log.Printf("error scanning doover: %s", err)
continue
}
stmtZapDoover.Exec(d.ID)
_, err = stmtZapDoover.Exec(d.ID)
if err != nil {
log.Printf("error deleting doover: %s", err)
continue
}
log.Printf("redeliverating %s try %d", rcpt, goarounds)
deliverate(goarounds, username, rcpt, msg)
} else if d.When.Before(nexttime) {

12
honk.go
View File

@ -479,7 +479,7 @@ func xzone(w http.ResponseWriter, r *http.Request) {
for rows.Next() {
var xid string
rows.Scan(&xid)
honkers = append(honkers, Honker{ XID: xid})
honkers = append(honkers, Honker{XID: xid})
}
rows.Close()
for i, _ := range honkers {
@ -927,8 +927,14 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
if wherefore == "zonk" {
xonk := getxonk(userinfo.UserID, what)
if xonk != nil {
stmtZonkDonks.Exec(xonk.ID)
stmtZonkIt.Exec(userinfo.UserID, what)
_, err := stmtZonkDonks.Exec(xonk.ID)
if err != nil {
log.Printf("error zonking: %s", err)
}
_, err = stmtZonkIt.Exec(userinfo.UserID, what)
if err != nil {
log.Printf("error zonking: %s", err)
}
if xonk.Whofore == 2 || xonk.Whofore == 3 {
zonk := Honk{
What: "zonk",