Skip to content

Commit 580ab5d

Browse files
committed
chore: quick update fix/version at 2025-10-18 20:49:51
1 parent 4b2de87 commit 580ab5d

File tree

20 files changed

+512
-980
lines changed

20 files changed

+512
-980
lines changed

assert/aaa.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
package assert
22

3+
import "github.com/pubgo/funk/v2/features"
4+
35
const Name = "assert"
6+
7+
var FeatureDebugMode = features.Bool("assert.debug_mode", false, "debug mode, pretty stack and error")

assert/must_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func init1Next() (err error) {
5757
return nil
5858
}
5959

60+
func TestDebugMode(t *testing.T) {
61+
assert1.Exit(assert1.FeatureDebugMode.Set("true"))
62+
assert1.Must(fmt.Errorf("test next"))
63+
}
64+
6065
func BenchmarkNoPanic(b *testing.B) {
6166
for i := 0; i < b.N; i++ {
6267
_ = func() (err error) {

assert/util.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ func must(err error, messageArgs ...any) {
7777
}
7878

7979
logErr(err, message, attrs...)
80+
81+
if FeatureDebugMode.GetValue() {
82+
_, _ = pp.Println(err)
83+
debug.PrintStack()
84+
}
85+
8086
panic(err)
8187
}
8288

component/cloudevent/client.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ import (
1010
mapset "github.com/deckarep/golang-set/v2"
1111
"github.com/nats-io/nats.go/jetstream"
1212
ants "github.com/panjf2000/ants/v2"
13+
"github.com/rs/zerolog"
14+
"github.com/samber/lo"
15+
"google.golang.org/protobuf/proto"
16+
"google.golang.org/protobuf/types/known/anypb"
17+
1318
"github.com/pubgo/funk/v2/assert"
1419
"github.com/pubgo/funk/v2/buildinfo/version"
1520
"github.com/pubgo/funk/v2/component/lifecycle"
1621
"github.com/pubgo/funk/v2/component/natsclient"
1722
"github.com/pubgo/funk/v2/errors"
18-
"github.com/pubgo/funk/v2/internal/anyhow"
1923
"github.com/pubgo/funk/v2/log"
2024
"github.com/pubgo/funk/v2/log/logfields"
2125
cloudeventpb "github.com/pubgo/funk/v2/proto/cloudevent"
@@ -24,10 +28,6 @@ import (
2428
"github.com/pubgo/funk/v2/stack"
2529
"github.com/pubgo/funk/v2/try"
2630
"github.com/pubgo/funk/v2/typex"
27-
"github.com/rs/zerolog"
28-
"github.com/samber/lo"
29-
"google.golang.org/protobuf/proto"
30-
"google.golang.org/protobuf/types/known/anypb"
3131
)
3232

3333
type Params struct {
@@ -346,7 +346,7 @@ func (c *Client) doErrHandler(streamName, consumerName string) jetstream.PullCon
346346
})
347347
}
348348

349-
func (c *Client) doHandler(meta *jetstream.MsgMetadata, msg jetstream.Msg, job *jobEventHandler, cfg *JobEventConfig) (gErr anyhow.Error) {
349+
func (c *Client) doHandler(meta *jetstream.MsgMetadata, msg jetstream.Msg, job *jobEventHandler, cfg *JobEventConfig) (gErr result.Error) {
350350
var timeout = lo.FromPtr(cfg.Timeout)
351351
ctx, cancel := context.WithTimeout(context.Background(), timeout)
352352
defer cancel()
@@ -388,31 +388,31 @@ func (c *Client) doHandler(meta *jetstream.MsgMetadata, msg jetstream.Msg, job *
388388
}()
389389

390390
var pb anypb.Any
391-
err := anyhow.ErrOf(proto.Unmarshal(msg.Data(), &pb)).
391+
err := result.ErrOf(proto.Unmarshal(msg.Data(), &pb)).
392392
Map(func(err error) error {
393393
return errors.WrapTag(err,
394394
errors.T("msg", "failed to unmarshal stream msg data to any proto"),
395395
errors.T("args", string(msg.Data())),
396396
)
397397
})
398-
if err.CatchErr(&gErr) {
398+
if err.Catch(&gErr) {
399399
return
400400
}
401401
args = &pb
402402

403-
dst := anyhow.Wrap(anypb.UnmarshalNew(args.(*anypb.Any), proto.UnmarshalOptions{})).
403+
dst := result.Wrap(anypb.UnmarshalNew(args.(*anypb.Any), proto.UnmarshalOptions{})).
404404
MapErr(func(err error) error {
405405
return errors.WrapTag(err,
406406
errors.T("msg", "failed to unmarshal any proto to proto msg"),
407407
errors.T("args", args),
408408
)
409409
})
410-
if dst.CatchErr(&gErr) {
410+
if dst.Catch(&gErr) {
411411
return
412412
}
413413

414414
ctx = createCtxWithContext(ctx, msgCtx)
415-
err = anyhow.ErrOf(job.handler(ctx, dst.GetValue())).
415+
err = result.ErrOf(job.handler(ctx, dst.GetValue())).
416416
Map(func(err error) error {
417417
return errors.WrapTag(err,
418418
errors.T("msg", "failed to do cloud job handler"),

internal/anyhow/aherrcheck/context.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

internal/anyhow/aherrcheck/errcheck.go

Lines changed: 0 additions & 47 deletions
This file was deleted.

internal/anyhow/aherrcheck/errcheck_test.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

internal/anyhow/anyhow.go

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)