Mercurial > gemma
diff pkg/imports/dsr.go @ 4408:911b1349a9bd
Added minimal error handling to deletion of SR.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 17 Sep 2019 12:52:29 +0200 |
parents | 9c6c65a628a3 |
children | ca6a5f722471 |
line wrap: on
line diff
--- a/pkg/imports/dsr.go Tue Sep 17 10:29:36 2019 +0200 +++ b/pkg/imports/dsr.go Tue Sep 17 12:52:29 2019 +0200 @@ -17,6 +17,7 @@ import ( "context" "database/sql" + "errors" "gemma.intevation.de/gemma/pkg/models" ) @@ -67,7 +68,19 @@ tx *sql.Tx, id int64, ) error { - _, err := tx.ExecContext(ctx, dsrStageDoneSQL, id) + result, err := tx.ExecContext(ctx, dsrStageDoneSQL, id) + if err != nil { + return err + } + rows, err := result.RowsAffected() + if err != nil { + return err + } + if rows == 0 { + return errors.New("Deletion failed. " + + "Propably Data outside the area of responsibility." + + "Or the data was already deleted by another user.") + } return err }