From 1973bc87f1c8c4d2c41641554ae13458edaddb99 Mon Sep 17 00:00:00 2001 From: qydysky Date: Wed, 26 Mar 2025 22:35:34 +0800 Subject: [PATCH] 1 (#36) --- errors/errors.go | 7 +++++++ errors/errors_test.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/errors/errors.go b/errors/errors.go index ab72a03..0353840 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -25,6 +25,13 @@ func (t Action) Error() string { return string(t) } +func (t Action) Unwrap() error { + return Error{ + action: t, + Reason: string(t), + } +} + type Error struct { Reason string action Action diff --git a/errors/errors_test.go b/errors/errors_test.go index ec0a4dd..adbdfa0 100644 --- a/errors/errors_test.go +++ b/errors/errors_test.go @@ -14,6 +14,12 @@ var a11 = a1.Append("1") func TestXxx(t *testing.T) { var err error + err = a0 + + if !Catch(err, a0) { + t.Fatal() + } + err = New("r0", a0) if !Catch(err, a0) { -- 2.39.2