From 10c2045593783d25c79da6334d62a38f24358685 Mon Sep 17 00:00:00 2001 From: lianxmfor <1034552569@qq.com> Date: Wed, 26 Jan 2022 10:10:53 +0800 Subject: [PATCH] fix(oomstore/errdefs): fix wrapped error does not print out the call stack --- pkg/errdefs/errdefs.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/errdefs/errdefs.go b/pkg/errdefs/errdefs.go index 55b86b8f8..12d3eb3c7 100644 --- a/pkg/errdefs/errdefs.go +++ b/pkg/errdefs/errdefs.go @@ -1,11 +1,19 @@ package errdefs +import ( + "fmt" +) + type errNotFound struct{ error } func (e errNotFound) Unwrap() error { return e.error } +func (e errNotFound) Error() string { + return fmt.Sprintf("%+v", e.error) +} + func NotFound(err error) error { if err == nil || IsNotFound(err) { return err @@ -19,6 +27,10 @@ func (e errInvalidAttribute) Unwrap() error { return e.error } +func (e errInvalidAttribute) Error() string { + return fmt.Sprintf("%+v", e.error) +} + func InvalidAttribute(err error) error { if err == nil || IsInvalidAttribute(err) { return err