Skip to content

Commit

Permalink
fix: Skip type conversion on error
Browse files Browse the repository at this point in the history
  • Loading branch information
viccon committed May 7, 2024
1 parent 53060d2 commit d8586a5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ func wrap[T, V any](fetchFn FetchFn[V]) FetchFn[T] {
}

func unwrap[V, T any](val T, err error) (V, error) {
if err != nil {
var zero V
return zero, err
}

v, ok := any(val).(V)
if !ok {
return v, ErrInvalidType
}

return v, err
}

Expand Down

0 comments on commit d8586a5

Please sign in to comment.