From: qydysky Date: Mon, 25 Mar 2024 16:33:09 +0000 (+0800) Subject: 1 X-Git-Tag: v0.28.20240325163746 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=1ad61cc14547ea820511c9f1e0da225cafe429b7;p=part%2F.git 1 --- diff --git a/errors/errors.go b/errors/errors.go index 83769b8..1d02ffc 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -6,12 +6,12 @@ import ( type Error struct { son interface{} - reason string + Reason string action string } func (t Error) Error() string { - return t.reason + return t.Reason } func Catch(e error, action string) bool { @@ -31,17 +31,20 @@ func Grow(e error, son Error) Error { son.son = v } else { son.son = Error{ - reason: v.Error(), + Reason: v.Error(), } } return son } -func New(reason string, action string) Error { - return Error{ - reason: reason, +func New(action string, reason ...string) (e Error) { + e = Error{ action: action, } + if len(reason) > 0 { + e.Reason = reason[0] + } + return } func Join(e ...error) error {