Skip to content

Commit 52b357e

Browse files
yhabteaboxzi
authored andcommitted
utils.InsertAndFetchId: Wrap errors
Imported from Icinga/icinga-notifications@2b32ff4
1 parent 603812e commit 52b357e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

database/utils.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,17 @@ func InsertAndFetchId(ctx context.Context, tx *sqlx.Tx, stmt string, args any) (
9797

9898
err = preparedStmt.Get(&lastInsertId, args)
9999
if err != nil {
100-
return 0, fmt.Errorf("failed to insert entry for type %T: %s", args, err)
100+
return 0, fmt.Errorf("failed to insert entry for type %T: %w", args, err)
101101
}
102102
} else {
103103
result, err := tx.NamedExecContext(ctx, stmt, args)
104104
if err != nil {
105-
return 0, fmt.Errorf("failed to insert entry for type %T: %s", args, err)
105+
return 0, fmt.Errorf("failed to insert entry for type %T: %w", args, err)
106106
}
107107

108108
lastInsertId, err = result.LastInsertId()
109109
if err != nil {
110-
return 0, fmt.Errorf("failed to fetch last insert id for type %T: %s", args, err)
110+
return 0, fmt.Errorf("failed to fetch last insert id for type %T: %w", args, err)
111111
}
112112
}
113113

0 commit comments

Comments
 (0)