We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I want to add error message to returned metadata,but it does not work.This is my code.
func ErrorServerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { resp, err = handler(ctx, req) if err != nil { data := make(map[string]string) data["exceptionResult"] = err.Error() errorMessage := &grpc_message.ErrorMessage{ ServiceName: ServiceName, Reason: err.Error(), Metadata: data, } //incomingContext, _ := metadata.FromIncomingContext(ctx) bytes, _ := json.Marshal(errorMessage) md, ok := metadata.FromOutgoingContext(ctx) if !ok { md = metadata.New(map[string]string{}) } md.Append("custom-key", string(bytes)) ctx = metadata.NewOutgoingContext(ctx, md) return nil, nil } return resp, err }
The text was updated successfully, but these errors were encountered:
@aranjans you can assign it to me
Sorry, something went wrong.
@baozi-2019 could you provide more context on why you are not returning the error (returning nil) from your interceptor?
@baozi-2019 you need to return a non-nil error in order to add the error message to the metadata
purnesh42H
No branches or pull requests
I want to add error message to returned metadata,but it does not work.This is my code.
The text was updated successfully, but these errors were encountered: