Skip to content

Commit

Permalink
refactor: sqlx - delete TypedError
Browse files Browse the repository at this point in the history
  • Loading branch information
nalgeon committed Apr 28, 2024
1 parent c6bdaf0 commit 1b55ad8
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/rhash/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (tx *Tx) set(key string, field string, value any) error {
}
_, err := tx.tx.Exec(sqlSet, args...)
if err != nil {
return sqlx.TypedError(err)
return err
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions internal/rstring/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func set(tx sqlx.Tx, key string, value any, at time.Time) error {
}
_, err := tx.Exec(sqlSet, args...)
if err != nil {
return sqlx.TypedError(err)
return err
}
return nil
}
Expand All @@ -260,7 +260,7 @@ func update(tx sqlx.Tx, key string, value any) error {
}
_, err := tx.Exec(sqlUpdate, args...)
if err != nil {
return sqlx.TypedError(err)
return err
}
return nil
}
2 changes: 1 addition & 1 deletion internal/rzset/inter.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (c InterCmd) store(tx sqlx.Tx) (int, error) {

res, err := tx.Exec(query, args...)
if err != nil {
return 0, sqlx.TypedError(err)
return 0, err
}

// Return the number of elements in the resulting set.
Expand Down
4 changes: 2 additions & 2 deletions internal/rzset/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (tx *Tx) Incr(key string, elem any, delta float64) (float64, error) {
}
_, err := tx.tx.Exec(sqlIncr1, args...)
if err != nil {
return 0, sqlx.TypedError(err)
return 0, err
}

var score float64
Expand Down Expand Up @@ -373,7 +373,7 @@ func (tx *Tx) add(key string, elem any, score float64) error {

_, err := tx.tx.Exec(sqlAdd, args...)
if err != nil {
return sqlx.TypedError(err)
return err
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/rzset/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (c UnionCmd) store(tx sqlx.Tx) (int, error) {

res, err := tx.Exec(query, args...)
if err != nil {
return 0, sqlx.TypedError(err)
return 0, err
}

// Return the number of elements in the resulting set.
Expand Down
5 changes: 0 additions & 5 deletions internal/sqlx/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,3 @@ func Select[T any](db Tx, query string, args []any,

return vals, err
}

// Returns typed errors for some specific cases.
func TypedError(err error) error {
return err
}

0 comments on commit 1b55ad8

Please sign in to comment.