From d10c62d485d44a1abf64446186eed9be48e91482 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Tue, 18 Jul 2017 09:21:35 +0200 Subject: [PATCH] Wrap typeurl returned errors with the provided url/type Signed-off-by: Kenfe-Mickael Laventure --- typeurl/types.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/typeurl/types.go b/typeurl/types.go index a93a5481b..3e845ec4e 100644 --- a/typeurl/types.go +++ b/typeurl/types.go @@ -10,6 +10,7 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/types" + "github.com/pkg/errors" ) const Prefix = "types.containerd.io" @@ -39,7 +40,7 @@ func TypeURL(v interface{}) (string, error) { // fallback to the proto registry if it is a proto message pb, ok := v.(proto.Message) if !ok { - return "", errdefs.ErrNotFound + return "", errors.Wrapf(errdefs.ErrNotFound, "type %s", reflect.TypeOf(v)) } return path.Join(Prefix, proto.MessageName(pb)), nil } @@ -116,7 +117,7 @@ func getTypeByUrl(url string) (urlType, error) { isProto: true, }, nil } - return urlType{}, errdefs.ErrNotFound + return urlType{}, errors.Wrapf(errdefs.ErrNotFound, "type with url %s", url) } func tryDereference(v interface{}) reflect.Type {