changeset 5595:bbc257dd9abf

Mixed bad error handling found by staticcheck.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 05 Aug 2022 12:22:06 +0200
parents 2b6c235e33b0
children 847de131893a
files pkg/controllers/report.go pkg/imports/sr.go
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/report.go	Fri Aug 05 12:14:44 2022 +0200
+++ b/pkg/controllers/report.go	Fri Aug 05 12:22:06 2022 +0200
@@ -159,6 +159,11 @@
 	conn := middleware.GetDBConn(req)
 
 	tx, err := conn.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
+	if err != nil {
+		http.Error(rw, "Error: "+err.Error(), http.StatusInternalServerError)
+		log.Errorf("%v\n", err)
+		return
+	}
 	defer tx.Rollback()
 
 	if err := action.Execute(ctx, tx, template); err != nil {
--- a/pkg/imports/sr.go	Fri Aug 05 12:14:44 2022 +0200
+++ b/pkg/imports/sr.go	Fri Aug 05 12:22:06 2022 +0200
@@ -741,8 +741,9 @@
 	}
 
 	if m.SurveyType != models.SurveyTypeMarking {
+		var index []byte
 
-		index, err := final.Bytes()
+		index, err = final.Bytes()
 		if err != nil {
 			return nil, err
 		}