proto, internal/errors: add Error sentinel, errors.Wrap
Add a sentinel proto.Error error which matches all errors returned by
packages in this module.
Document that protoregistry.NotFound is an exact sentinel value for
performance reasons.
Add a Wrap function to the internal/errors package and use it to wrap
errors from outside sources (resolvers). Wrapped errors match
proto.Error.
Fixes golang/protobuf#1021.
Change-Id: I45567df3fd6c8dc9a5caafdb55654827f6fb1941
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/215338
Reviewed-by: Joe Tsai <joetsai@google.com>
diff --git a/internal/impl/decode.go b/internal/impl/decode.go
index a2993d4..6e78faa 100644
--- a/internal/impl/decode.go
+++ b/internal/impl/decode.go
@@ -189,7 +189,7 @@
if err == preg.NotFound {
return out, errUnknown
}
- return out, err
+ return out, errors.New("%v: unable to resolve extension %v: %v", mi.Desc.FullName(), num, err)
}
}
xi := getExtensionFieldInfo(xt)