Skip to content

Commit 7726faf

Browse files
committed
refactor: remove deprecated Result function
1 parent a9805a0 commit 7726faf

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

try/try.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,9 @@ package try
33
import (
44
"github.com/pubgo/funk"
55
"github.com/pubgo/funk/errors"
6-
"github.com/pubgo/funk/generic"
7-
"github.com/pubgo/funk/result"
86
"github.com/pubgo/funk/stack"
97
)
108

11-
// Result
12-
// Deprecated: use result.Try instead
13-
func Result[T any](fn func() result.Result[T]) (g result.Result[T]) {
14-
if fn == nil {
15-
g = g.WithErr(errors.WrapStack(errors.New("[fn] is nil")))
16-
return
17-
}
18-
19-
defer func() {
20-
if err := errors.Parse(recover()); !generic.IsNil(err) {
21-
g = g.WithErr(errors.WrapStack(err))
22-
}
23-
24-
if g.IsErr() {
25-
g = g.WithErr(errors.WrapKV(g.Err(), "fn_stack", stack.CallerWithFunc(fn)))
26-
}
27-
}()
28-
29-
g = fn()
30-
return
31-
}
32-
339
func WithErr(gErr *error, fn func() error) {
3410
if fn == nil {
3511
*gErr = errors.WrapStack(errors.New("[fn] is nil"))

0 commit comments

Comments
 (0)