diff options
| author | Shulhan <ms@kilabit.info> | 2021-07-30 18:42:15 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-07-30 18:42:15 +0700 |
| commit | 8379a3ac6385e811410ec512b414655926163c8d (patch) | |
| tree | 7788cb3ca69e0ec3a49afd84fe8543d7032d286b /lib/errors/errors.go | |
| parent | dab97a3491f28010f81554e717076e1434604b48 (diff) | |
| download | pakakeh.go-8379a3ac6385e811410ec512b414655926163c8d.tar.xz | |
lib/errors: return the internal error only if its not nil on Unwrap
If the internal error is nil, the Unwrap method will return the instance
of e itself.
Diffstat (limited to 'lib/errors/errors.go')
| -rw-r--r-- | lib/errors/errors.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/errors/errors.go b/lib/errors/errors.go index 35b74d1c..13e3b995 100644 --- a/lib/errors/errors.go +++ b/lib/errors/errors.go @@ -58,8 +58,12 @@ func (e *E) Error() string { } // -// Unwrap return the internal error. +// Unwrap return the internal error only if its not nil; otherwise it will +// return the e itself. // func (e *E) Unwrap() error { - return e.err + if e.err != nil { + return e.err + } + return e } |
