Skip to content

Instantly share code, notes, and snippets.

@alesj
Last active September 19, 2022 12:05
Skywalker:quarkus_cl130 alesj$ grpcurl -vv -plaintext -d '{"name":"Francesco"}' localhost:9000 helloworld.Greeter/SayHello
Resolved method descriptor:
rpc SayHello ( .helloworld.HelloRequest ) returns ( .helloworld.HelloReply );
Request metadata to send:
(empty)
Response headers received:
(empty)
Response trailers received:
content-type: application/grpc
Sent 1 request and received 0 responses
ERROR:
Code: Internal
Message:
---
@ApplicationScoped
@GlobalInterceptor
public class ExceptionInterceptor implements ServerInterceptor {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
try {
return next.startCall(call, headers);
} catch (Throwable t) {
Metadata trailers = Status.trailersFromThrowable(t);
if (trailers != null) {
headers.merge(trailers);
}
Status status = Status.fromThrowable(t).withDescription(t.getMessage());
call.close(status, headers);
return new ServerCall.Listener<ReqT>() {
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment