Skip to content

Commit 4aee6c0

Browse files
committed
chore: quick update fix/version at 2025-09-16 22:00:15
1 parent 82d51f9 commit 4aee6c0

File tree

8 files changed

+26
-33
lines changed

8 files changed

+26
-33
lines changed

component/cloudevent/publisher.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (c *Client) publish(ctx context.Context, topic string, args proto.Message,
133133
Log(func(e *zerolog.Event) {
134134
e.Str(logfields.Msg, "failed to marshal args to any proto")
135135
}).
136-
Unwrap(&gErr)
136+
UnwrapErr(&gErr)
137137
if gErr != nil {
138138
return
139139
}
@@ -143,7 +143,7 @@ func (c *Client) publish(ctx context.Context, topic string, args proto.Message,
143143
Log(func(e *zerolog.Event) {
144144
e.Str(logfields.Msg, "failed to marshal any proto to bytes")
145145
}).
146-
Unwrap(&gErr)
146+
UnwrapErr(&gErr)
147147
if gErr != nil {
148148
return
149149
}
@@ -167,7 +167,7 @@ func (c *Client) publish(ctx context.Context, topic string, args proto.Message,
167167
Log(func(e *zerolog.Event) {
168168
e.Str(logfields.Msg, fmt.Sprintf("failed to publish msg to stream, topic=%s msg_id=%s", topic, msgId))
169169
}).
170-
Unwrap(&gErr)
170+
UnwrapErr(&gErr)
171171
if gErr != nil {
172172
return
173173
}

env/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func Key(key string) string {
120120

121121
func LoadFiles(files ...string) (r result.Error) {
122122
files = lo.Filter(files, func(item string, index int) bool { return pathutil.IsExist(item) })
123-
if result.CatchErr(&r, godotenv.Load(files...)) {
123+
if result.Catch(&r, godotenv.Load(files...)) {
124124
return
125125
}
126126

v2/result/api.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,25 @@ func WrapFn[T any](fn func() (T, error)) Result[T] {
106106
return Result[T]{err: err}
107107
}
108108

109-
func CatchErr(setter ErrSetter, err error, contexts ...context.Context) bool {
109+
func Catch(setter ErrSetter, err error, contexts ...context.Context) bool {
110110
return catchErr(newError(err), setter, nil, contexts...)
111111
}
112112

113-
func Catch(rawSetter *error, err error, contexts ...context.Context) bool {
113+
func CatchErr(rawSetter *error, err error, contexts ...context.Context) bool {
114114
return catchErr(newError(err), nil, rawSetter, contexts...)
115115
}
116116

117117
func MapTo[T, U any](r Result[T], fn func(T) U) Result[U] {
118118
if r.IsErr() {
119-
err := errors.WrapCaller(r.getErr(), 1)
120-
return Fail[U](err)
119+
return Fail[U](errors.WrapCaller(r.getErr(), 1))
121120
}
122121

123122
return OK(fn(r.getValue()))
124123
}
125124

126125
func FlatMapTo[T, U any](r Result[T], fn func(T) Result[U]) Result[U] {
127126
if r.IsErr() {
128-
err := errors.WrapCaller(r.getErr(), 1)
129-
return Fail[U](err)
127+
return Fail[U](errors.WrapCaller(r.getErr(), 1))
130128
}
131129

132130
return fn(r.getValue())

v2/result/error.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,11 @@ func (e Error) Inspect(fn func(error)) Error {
7171

7272
func (e Error) InspectErr(fn func(error)) Error { return e.Inspect(fn) }
7373

74-
func (e Error) Unwrap() error { return e.err }
75-
func (e Error) UnwrapErr(setter ErrSetter, contexts ...context.Context) bool {
76-
return catchErr(e, setter, nil, contexts...)
77-
}
78-
79-
func (e Error) Catch(setter *error, ctx ...context.Context) bool {
74+
func (e Error) CatchErr(setter *error, ctx ...context.Context) bool {
8075
return catchErr(e, nil, setter, ctx...)
8176
}
8277

83-
func (e Error) CatchErr(setter ErrSetter, ctx ...context.Context) bool {
78+
func (e Error) Catch(setter ErrSetter, ctx ...context.Context) bool {
8479
return catchErr(e, setter, nil, ctx...)
8580
}
8681

v2/result/interface.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ package result
22

33
import "context"
44

5-
type Catchable interface {
6-
Catch(err *error, contexts ...context.Context) bool
7-
CatchErr(err ErrSetter, contexts ...context.Context) bool
8-
}
9-
105
// Checkable defines types that can be checked for Ok/Error state
116
type Checkable interface {
127
IsOK() bool
@@ -20,7 +15,12 @@ type ErrSetter interface {
2015
setErrorInner()
2116
}
2217

18+
type Catchable interface {
19+
CatchErr(err *error, contexts ...context.Context) bool
20+
Catch(err ErrSetter, contexts ...context.Context) bool
21+
}
22+
2323
type UnWrapper[T any] interface {
24-
Unwrap(setter *error, contexts ...context.Context) T
25-
UnwrapErr(setter ErrSetter, contexts ...context.Context) T
24+
UnwrapErr(setter *error, contexts ...context.Context) T
25+
Unwrap(setter ErrSetter, contexts ...context.Context) T
2626
}

v2/result/proxy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
func TestProxy(t *testing.T) {
1010
var gErr error
1111
var err = ErrProxyOf(&gErr)
12-
Errorf("test proxy error").Log().CatchErr(&err)
12+
Errorf("test proxy error").Log().Catch(&err)
1313
assert.NotNil(t, gErr)
1414
assert.NotNil(t, err.GetErr())
1515
assert.Equal(t, gErr, err.GetErr())

v2/result/result.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ func (r Result[T]) Must(events ...func(e *zerolog.Event)) T {
8282
return r.getValue()
8383
}
8484

85-
func (r Result[T]) Catch(setter *error, ctx ...context.Context) bool {
85+
func (r Result[T]) CatchErr(setter *error, ctx ...context.Context) bool {
8686
return catchErr(newError(r.err), nil, setter, ctx...)
8787
}
8888

89-
func (r Result[T]) CatchErr(setter ErrSetter, ctx ...context.Context) bool {
89+
func (r Result[T]) Catch(setter ErrSetter, ctx ...context.Context) bool {
9090
return catchErr(newError(r.err), setter, nil, ctx...)
9191
}
9292

@@ -192,15 +192,15 @@ func (r Result[T]) WrapErr(err *errors.Err, tags ...errors.Tag) Result[T] {
192192
return Result[T]{err: errors.WrapTag(errors.WrapCaller(err, 1), tags...)}
193193
}
194194

195-
func (r Result[T]) Unwrap(setter *error, contexts ...context.Context) T {
195+
func (r Result[T]) UnwrapErr(setter *error, contexts ...context.Context) T {
196196
ret, err := unwrapErr(r, setter, nil, contexts...)
197197
if err != nil {
198198
*setter = errors.WrapCaller(err, 1)
199199
}
200200
return ret
201201
}
202202

203-
func (r Result[T]) UnwrapErr(setter ErrSetter, contexts ...context.Context) T {
203+
func (r Result[T]) Unwrap(setter ErrSetter, contexts ...context.Context) T {
204204
ret, err := unwrapErr(r, nil, setter, contexts...)
205205
if err != nil {
206206
setError(setter, errors.WrapCaller(err, 1))

v2/result/result_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ func TestErrOf(t *testing.T) {
4747
resultchecker.RegisterErrCheck(log.RecordErr())
4848

4949
var err result.Error
50-
if fn1().CatchErr(&err, ctx) {
50+
if fn1().Catch(&err, ctx) {
5151
errors.Debug(err.GetErr())
5252
}
5353
}
5454

5555
func fn1() (r result.Result[string]) {
56-
if fn3().CatchErr(&r) {
56+
if fn3().Catch(&r) {
5757
return
5858
}
5959

60-
val := fn2().UnwrapErr(&r)
60+
val := fn2().Unwrap(&r)
6161
if r.IsErr() {
6262
return
6363
}
@@ -70,7 +70,7 @@ func fn2() (r result.Result[string]) {
7070
InspectErr(func(err error) {
7171
log.Err(err).Msg("test error")
7272
}).
73-
CatchErr(&r)
73+
Catch(&r)
7474
if r.IsErr() {
7575
return
7676
}

0 commit comments

Comments
 (0)