-
Notifications
You must be signed in to change notification settings - Fork 420
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
Add RPCError and Status #1656
Add RPCError and Status #1656
Conversation
Motivation: One mistake we made in v1 was having the status also be an error. This leads to interesting situations where a status with code 'ok' can be treated as an error. Here, we split them into two objects. Modifications: - Add a new GRPCCore target - Add RPCError and Status types and tests Result: RPCError and status are separate types.
/// An error representing the outcome of an RPC. | ||
/// | ||
/// See also ``Status``. | ||
public struct RPCError: @unchecked Sendable, Hashable, Error { |
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.
Can we add a comment why we use @unchecked
here
} | ||
} | ||
|
||
/// Metadata associated with the error. |
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.
Couple of questions here:
- From the proposal I remember that this includes all metadata when I receive this error on the client side right? Can we document this?
- If I throw this error on the server side will all metadata be attached to the underlying transport response? Could we also document this?
|
||
/// A status object represents the outcome of an RPC. | ||
/// | ||
/// Each ``Status`` is composed of a ``Status/code-swift.property`` and ``Status/message``. Each |
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 first docc link is very interesting :D
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.
Status
? 🤨
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.
I mean this Status/code-swift.property
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.
Off-by-one error ;)
Yeah, docc symbols aren't case sensitive so Code
-the-type and code
-the-property are ambiguous otherwise.
Motivation:
One mistake we made in v1 was having the status also be an error. This leads to interesting situations where a status with code 'ok' can be treated as an error.
Here, we split them into two objects.
Modifications:
Result:
RPCError and status are separate types.