Skip to content

How to return a custom Error body using Vanguard and HTTP annotations #826

Answered by jhump
FotiadisM asked this question in Q&A
Discussion options

You must be logged in to vote

The connect.ErrorWriter would use the Connect error format:
https://connectrpc.com/docs/protocol#error-end-stream

This is nearly identical to what vanguard-go already does. The subtle difference is that IIRC vanguard-go serializes the code as a number instead of a string and the detail messages, when present, are a little bit different. But it's still a JSON response with the same information.

The reason vanguard uses the format it does was meant for compatibility with grpc-gateway and Envoy's gRPC-JSON transcoding filter, which both also implement HTTP transcoding. Vanguard intentionally doesn't provide a way to customize the error body because it could pose a potential interop issue wit…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by FotiadisM
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants