Last active
September 19, 2022 12:05
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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