~sircmpwn/core-go

e7b8e02696a1f1bcd365baa7f67fa360a201bf5b — Simon Ser 7 months ago 7f5f707
database: print both errors in WithTx

Make it easier to debug panics by printing both errors instead of
sending one of them to /dev/null.
1 files changed, 6 insertions(+), 1 deletions(-)

M database/middleware.go
M database/middleware.go => database/middleware.go +6 -1
@@ 5,6 5,7 @@ import (
	"database/sql"
	sqldriver "database/sql/driver"
	"errors"
	"fmt"
	"net/http"
)



@@ 69,7 70,11 @@ func WithTx(ctx context.Context, opts *sql.TxOptions, fn func(tx *sql.Tx) error)
		return err
	}
	if txErr != nil && txErr != sql.ErrTxDone {
		panic(txErr)
		if err != nil {
			panic(fmt.Errorf("Transaction error: %v\nClosure error: %v", txErr, err))
		} else {
			panic(txErr)
		}
	}
	return err
}