-
Notifications
You must be signed in to change notification settings - Fork 2.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
Better grpc error strings #87
Comments
+1 |
1 similar comment
+1 |
I don't think it is better to lose error code in the message. |
Maybe it is OK to lose error code in the message and make it cleaner. GRPC error code is translated into HTTP status code anyway in the next few line - https://github.com/gengo/grpc-gateway/blob/master/runtime/errors.go#L88 . |
How about this then: {
"error": "Unauthenticated",
"code": 16
} |
@floridoo It is not too bad. But I still don't understand what's wrong in the current format of the message. |
If I understand correctly, what people don't like is that the strings I don't feel very strongly about this either way. |
I prefer structured log than combined log because we can take what we want from logs easily. |
OK. I will accept it if you give me a pull request with the style: {
"error": "Unauthenticated",
"code": 16
} |
Bumping this issue. Is there any way to get the string representation of the code? If exposed to public users, the code doesn't really provide much value. They would have to know to look it up in the codes proto file. Google Cloud for example returns both which is nice. https://cloud.google.com/apis/design/errors#http_mapping |
It's possible to customize error returns already. Changing the error return structure at this point would break many users. For 2.0 (if that ever comes around) we want to have a serious look at the error returns again. See https://grpc-ecosystem.github.io/grpc-gateway/docs/customizingyourgateway.html. |
Errors currently look similar to this:
Wouldn't it be better to set
error
just to the description?Example:
This can easily be achieved by replacing
err.Error()
withgrpc.ErrorDesc(err)
on this line:https://github.com/gengo/grpc-gateway/blob/master/runtime/errors.go#L77
I can send a pull request if wished.
The text was updated successfully, but these errors were encountered: