You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using connect.NewError, it is not possible create an error such that err.IsWireError() will return true.
This capability is particularly useful for dealing with bidi streaming APIs that represent a conversation, where each response message correlates with a request message. It is common for these kinds of APIs to support partial success by having a response message indicate a failure just for that one request message. Often such APIs use google.rpc.Status in the response message to indicate a possible failure. Sometimes they do not.
For this sort of use, it is commonplace for the calling Go code to translate that status into an error. Since the error was received over the wire during an RPC call, it should technically be a wire error, so that any other handling/propagation logic higher up the stack can react to it correctly.
This could be addressed as easily as introducing a new NewWireError function with the same signature and semantics as NewError except that the returned error will return true when err.IsWireError() is called.
The text was updated successfully, but these errors were encountered:
Huh, I'd never noticed that portion of the reflection API. TIL!
Happy to take a PR for this. I'm 50/50 on whether we ought to special-case NewWireError or anticipate more things down the road and add NewErrorOpt(Code, error, ...ErrorOption) (function name is terrible, but you get the idea).
Currently, only the Connect runtime can create errors that return true
when tested by `IsWireError`. However, streaming RPCs commonly indicate
partial failure by including an error code and message in their response
message. To propagate these partial failures properly, clients need a
way to construct wire errors. This commit adds `NewWireError` to satisfy
this use case.
Fixes#420.
When using
connect.NewError
, it is not possible create an error such thaterr.IsWireError()
will return true.This capability is particularly useful for dealing with bidi streaming APIs that represent a conversation, where each response message correlates with a request message. It is common for these kinds of APIs to support partial success by having a response message indicate a failure just for that one request message. Often such APIs use
google.rpc.Status
in the response message to indicate a possible failure. Sometimes they do not.For this sort of use, it is commonplace for the calling Go code to translate that status into an error. Since the error was received over the wire during an RPC call, it should technically be a wire error, so that any other handling/propagation logic higher up the stack can react to it correctly.
This could be addressed as easily as introducing a new
NewWireError
function with the same signature and semantics asNewError
except that the returned error will return true whenerr.IsWireError()
is called.The text was updated successfully, but these errors were encountered: