Mercurial > gemma
changeset 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 | 8c0f2377ff47 |
children | d6c38a22c71e |
files | pkg/imports/dsr.go |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
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 }