From: qydysky Date: Thu, 27 Mar 2025 13:14:58 +0000 (+0800) Subject: 1 (#37) X-Git-Tag: v0.28.20250327131507 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=ae7c4270bde6f2093597e87b91450df00477612b;p=part%2F.git 1 (#37) --- diff --git a/errors/errors.go b/errors/errors.go index 0353840..b70e86c 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -25,13 +25,19 @@ func (t Action) Error() string { return string(t) } -func (t Action) Unwrap() error { - return Error{ - action: t, - Reason: string(t), +func (t Action) Unwrap() []error { + return []error{ + Error{ + action: t, + Reason: string(t), + }, } } +func (t Action) Catch(e error) bool { + return Catch(e, t) +} + type Error struct { Reason string action Action diff --git a/errors/errors_test.go b/errors/errors_test.go index adbdfa0..5ed5f89 100644 --- a/errors/errors_test.go +++ b/errors/errors_test.go @@ -16,10 +16,21 @@ func TestXxx(t *testing.T) { err = a0 + if !Catch(err, a0) || !a0.Catch(err) { + t.Fatal() + } + + err = Join(err, a1) + err = Join(a11, err) + if !Catch(err, a0) { t.Fatal() } + if !a0.Catch(err) || !a1.Catch(err) || !a11.Catch(err) { + t.Fatal() + } + err = New("r0", a0) if !Catch(err, a0) {