more info about some errors
Ted Unangst tedu@tedunangst.com
Fri, 30 Aug 2019 10:16:59 -0400
3 files changed,
12 insertions(+),
11 deletions(-)
M
activity.go
→
activity.go
@@ -1060,28 +1060,28 @@ }
return true } -func investigate(name string) *Honker { +func investigate(name string) (*Honker, error) { if name == "" { - return nil + return nil, fmt.Errorf("no name") } if name[0] == '@' { name = gofish(name) } if name == "" { - return nil + return nil, fmt.Errorf("no name") } log.Printf("digging up some info on %s", name) obj, err := GetJunkFast(name) if err != nil { log.Printf("error investigating honker: %s", err) - return nil + return nil, err } t, _ := obj.GetString("type") if !isactor(t) { log.Printf("it's not a person! %s", name) - return nil + return nil, err } xid, _ := obj.GetString("id") handle, _ := obj.GetString("preferredUsername") - return &Honker{XID: xid, Handle: handle} + return &Honker{XID: xid, Handle: handle}, nil }
M
honk.go
→
honk.go
@@ -480,7 +480,7 @@ }
func ximport(w http.ResponseWriter, r *http.Request) { xid := r.FormValue("xid") - p := investigate(xid) + p, _ := investigate(xid) if p != nil { xid = p.XID }@@ -1426,8 +1426,9 @@ flavor := "presub"
if peep == "peep" { flavor = "peep" } - p := investigate(url) - if p == nil { + p, err := investigate(url) + if err != nil { + http.Error(w, "error investigating: "+err.Error(), http.StatusInternalServerError) log.Printf("failed to investigate honker") return }@@ -1435,7 +1436,7 @@ url = p.XID
if name == "" { name = p.Handle } - _, err := stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos) + _, err = stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos) if err != nil { log.Print(err) return