diff pkg/imports/dsr.go @ 5128:7bd9c5161836

Handle deletion of non-existent sounding results gracefully
author Tom Gottfried <tom@intevation.de>
date Fri, 27 Mar 2020 12:20:48 +0100
parents 59a99655f34d
children f2204f91d286
line wrap: on
line diff
--- a/pkg/imports/dsr.go	Fri Mar 27 10:33:39 2020 +0100
+++ b/pkg/imports/dsr.go	Fri Mar 27 12:20:48 2020 +0100
@@ -112,8 +112,13 @@
 		dsr.BottleneckID, dsr.Date.Time)
 
 	var id int64
-	if err := tx.QueryRowContext(ctx, dsrFindSQL,
-		dsr.BottleneckID, dsr.Date.Time).Scan(&id); err != nil {
+	switch err := tx.QueryRowContext(ctx, dsrFindSQL,
+		dsr.BottleneckID, dsr.Date.Time).Scan(&id); err {
+	case sql.ErrNoRows:
+		return nil, UnchangedError("Sounding result does not exist")
+	case nil:
+		// Continue
+	default:
 		return nil, err
 	}