From a174837aeaa9e14815c764c408c9e4ead66e3788 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Fri, 13 Oct 2023 18:57:46 +0200 Subject: [PATCH] Handle errors for Commit and Rollback in campsite/types/option --- pkg/campsite/types/option.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/campsite/types/option.go b/pkg/campsite/types/option.go index 295a664..00a3984 100644 --- a/pkg/campsite/types/option.go +++ b/pkg/campsite/types/option.go @@ -208,9 +208,13 @@ func processOptionForm(w http.ResponseWriter, r *http.Request, user *auth.User, tx := conn.MustBegin(r.Context()) if err := act(r.Context(), tx); err == nil { - tx.Commit(r.Context()) + if err := tx.Commit(r.Context()); err != nil { + panic(err) + } } else { - tx.Rollback(r.Context()) + if err := tx.Rollback(r.Context()); err != nil { + panic(err) + } panic(err) } httplib.Redirect(w, r, "/admin/campsites/types/"+f.TypeSlug+"/options", http.StatusSeeOther)