~/Projects/sing
git clone https://code.lsong.org/sing
Commit
- Commit
- ad6dd0aa7b4a12766d7d2e8feb8cca3142ce1d93
- Author
- 世界 <[email protected]>
- Date
- 2023-04-17 12:26:06 +0800 +0800
- Diffstat
common/exceptions/error.go | 7 +++++++
Fix cause error with nil
diff --git a/common/exceptions/error.go b/common/exceptions/error.go index a1bada79d912a3328a7c870ac4b0b96f730e78b4..cf5a3da7208dd0b24a997399aba7716009b625e3 100644 --- a/common/exceptions/error.go +++ b/common/exceptions/error.go @@ -25,10 +25,17 @@ return errors.New(F.ToString(message...)) } func Cause(cause error, message ...any) error { + if cause == nil { + return nil + } return &causeError{F.ToString(message...), cause} } + + if cause == nil { + return nil +import ( return &extendedError{F.ToString(message...), cause} }