-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grpcerrors: adapt grpcerrors to support more enriched error structures #5203
base: master
Are you sure you want to change the base?
Conversation
I still need to finish the v1 compatibility tests. I also discovered a bug in typeurl while I was working on this and that's filed here: containerd/typeurl#47. |
3782c05
to
ab04318
Compare
f64f405
to
f91d4c7
Compare
// stack.Stack is affected by the same bug as the other | ||
// typed errors so reuse that marshaling function to | ||
// marshal the stack trace. | ||
return marshalTypedError(st) | ||
} | ||
|
||
func Code(err error) codes.Code { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code here looks good and favors the right error code but it might be good to define that in the docs.
f91d4c7
to
859c4ea
Compare
I tried to do this with just using the |
2731511
to
7fe8b20
Compare
The grpcerrors package has been updated to support more enriched error structures. The serialization structure has been changed to capture the original structure of the error and to serialize and deserialize into that same structure. Wrapped errors should be maintained with the same structure for unwrapping. `Unwrap() []error` is now supported so `errors.Join` and anything else that wraps multiple errors can now be used and are serialized/deserialized correctly. More methods of determining the grpc code are now supported and they will respect error wrapping. The errors in `github.com/containerd/errdefs` are now also used for mapping error codes with more likely to appear in the future. The marshaling will marshal both the new format and the old format in a way where a client that reads either will succeed. That makes this method compatible with old clients. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
7fe8b20
to
80dd115
Compare
The grpcerrors package has been updated to support more enriched error structures.
The serialization structure has been changed to capture the original structure of the error and to serialize and deserialize into that same structure. Wrapped errors should be maintained with the same structure for unwrapping.
Unwrap() []error
is now supported soerrors.Join
and anything else that wraps multiple errors can now be used and are serialized/deserialized correctly.More methods of determining the grpc code are now supported and they will respect error wrapping. The errors in
github.com/containerd/errdefs
are now also used for mapping error codes with more likely to appear in the future.The marshaling will marshal both the new format and the old format in a way where a client that reads either will succeed. That makes this method compatible with old clients.