grpc-gateway: customize the error return

If the input type is error, gateway will return a json.

I need to customize the message. Is there a way ?

➜  ~ git:(master) ✗ curl 'localhost:9998/v1/example/echo?name=dddd'
{"error":"strconv.ParseInt: parsing \"dddd\": invalid syntax","code":3}%

the name is int32

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 21 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I think this can be closed now that https://github.com/grpc-ecosystem/grpc-gateway/pull/515 has been merged.

Hi, I created a PR #409 , it’s almost the same with #397 .
For we are blocked by this issue, if there is anything I can help with, please let me know.
Thank you!

Have a look at this PR: https://github.com/grpc-ecosystem/grpc-gateway/pull/397

Is there a specific reason why you would want to customize the message? Will a HTTP 400 suffice?

Do we have a workaround for this? I think that the issue OP addressed hasn’t been resolved. I would like to hide the implementation details from the user. For example, a message like this exposes unnecessary information:

strconv.ParseInt: parsing \"-3000000000000000000000000000000000000\": value out of range

I do not know #51 whether solve this problem. Let the project member to close this issue.