Fix error log reporting

This commit is contained in:
Eli Ribble 2026-02-09 22:34:07 +00:00
parent b263d50b76
commit f78515cc07
No known key found for this signature in database
2 changed files with 7 additions and 2 deletions

View file

@ -42,7 +42,7 @@ func (sr Nuisance) addNotificationEmail(ctx context.Context, txn bob.Tx, email s
}
_, err := models.PublicreportNotifyPhoneNuisances.Insert(&setter).Exec(ctx, txn)
if err != nil {
return newErrorWithCode("internal-error", "Failed to save new notification row")
return newErrorWithCode("internal-error", "Failed to save new notification email row")
}
return nil
}
@ -56,7 +56,7 @@ func (sr Nuisance) addNotificationPhone(ctx context.Context, txn bob.Tx, phone t
}
_, err = models.PublicreportNotifyPhoneNuisances.Insert(&setter).Exec(ctx, txn)
if err != nil {
return newErrorWithCode("internal-error", "Failed to save new notification row")
return newErrorWithCode("internal-error", "Failed to save new notification phone row")
}
return nil
}

View file

@ -42,6 +42,7 @@ func postRegisterNotifications(w http.ResponseWriter, r *http.Request) {
}
e := report.SaveReporter(ctx, txn, report_id, name, email, phone, has_consent)
if e != nil {
log.Error().Err(e).Str("name", name).Msg("Failed to save reporter")
http.Redirect(w, r, fmt.Sprintf("/error?code=%s&report=%s", e.Code(), report_id), http.StatusFound)
return
}
@ -49,12 +50,14 @@ func postRegisterNotifications(w http.ResponseWriter, r *http.Request) {
if has_subscribe {
e := report.RegisterSubscriptionEmail(ctx, txn, email)
if e != nil {
log.Error().Err(e).Str("email", email).Msg("Failed to register subscription email")
http.Redirect(w, r, fmt.Sprintf("/error?code=%s&report=%s", e.Code(), report_id), http.StatusFound)
}
}
if has_notification {
e := report.RegisterNotificationEmail(ctx, txn, report_id, email)
if e != nil {
log.Error().Err(e).Str("email", email).Msg("Failed to register notification email")
http.Redirect(w, r, fmt.Sprintf("/error?code=%s&report=%s", e.Code(), report_id), http.StatusFound)
}
}
@ -63,12 +66,14 @@ func postRegisterNotifications(w http.ResponseWriter, r *http.Request) {
if has_subscribe {
e := report.RegisterSubscriptionPhone(ctx, txn, *phone)
if e != nil {
log.Error().Err(e).Str("phone", phone_str).Msg("Failed to register subscription phone")
http.Redirect(w, r, fmt.Sprintf("/error?code=%s&report=%s", e.Code(), report_id), http.StatusFound)
}
}
if has_notification {
e := report.RegisterNotificationPhone(ctx, txn, report_id, *phone)
if e != nil {
log.Error().Err(e).Str("phone", phone_str).Msg("Failed to register notification phone")
http.Redirect(w, r, fmt.Sprintf("/error?code=%s&report=%s", e.Code(), report_id), http.StatusFound)
}
}