]> 127.0.0.1 Git - part/.git/commitdiff
1 (#37) v0.28.20250327131507
authorqydysky <qydysky@foxmail.com>
Thu, 27 Mar 2025 13:14:58 +0000 (21:14 +0800)
committerGitHub <noreply@github.com>
Thu, 27 Mar 2025 13:14:58 +0000 (21:14 +0800)
errors/errors.go
errors/errors_test.go

index 03538409a0d95c6bebd8dba53432fa00089c3c39..b70e86c834ead2caaa090c5b84922189d27d1fd7 100644 (file)
@@ -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
index adbdfa0a916b20d1ef6d16dfba7d71619134cf63..5ed5f89d31e87906967c0763031879ced4fede14 100644 (file)
@@ -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) {