func postHandle(c cat.Cat, tran cat.Transaction, imagePath string, w http.ResponseWriter, err *error, handleOk *bool) { p := recover() if p != nil { c.LogPanic(p) tran.SetStatus(p) log.WithFields(log.Fields{"uri": imagePath}).Error(*err) } if *handleOk { tran.SetStatus("0") tran.Complete() } else { tran.SetStatus(*err) tran.Complete() } if p != nil || *err != nil { http.Error(w, http.StatusText(404), 404) } }