-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Application cannot return errors with gprc.Code(err) != codes.Unknown
, errors are noisy, codes have no Stringer
#92
Comments
This is good catch. I planned to fix this before releasing but forgot to do On Tue, Mar 3, 2015 at 2:08 PM, Tv notifications@github.com wrote:
|
okay, this is actually a misuse. We do not expect users to set error code in their service handler implementation. They should simply return nil, fmt.Errorf("too grumpy to greet"). We should have had an example for this. But I probably should handle this case as well to obey whatever error code the server application sets if it does. Let me think ... |
If what you're saying is going to hold, then it sounds like However, consider the implications: if Codes are only supposed to be created by And yes, more clarity into intents of the mechanism is most welcome. |
On Wed, Mar 4, 2015 at 6:41 PM, Tv notifications@github.com wrote:
|
I expected to see code=15, now I see code=2 wrapping a code=15.
My reading of the source (https://github.com/grpc/grpc-go/blob/master/server.go#L246 , https://github.com/grpc/grpc-go/blob/master/rpc_util.go#L227 ) says convertCode should have
if err, ok := err.(rpcError); ok { return err.code }
.That still leaves the textual double-wrapping; it seems that should not be done on the server-side for
rpcError
, just sendrpcError.desc
if the error is agrpcError
.Also, could there be a little less textual wrapping? And could those codes get a
go stringer
on them? Here's what might be ideal:and only start doing quoting if the message is "hostile", as in contains
\n
etc. That would require defining a safe set of runes.The text was updated successfully, but these errors were encountered: