Handling errors
You may have already gone through the Handling errors section in Chapter 10, gRPC Fundamentals, where google.rpc.Status
and gRPC status codes are discussed. You may like to revisit this section before going through this section.
io.grpc.ServerInterceptor
is a thread-safe interface for intercepting the incoming calls that can be used for cross-cutting calls, such as authentication and authorization, logging, and monitoring. Let's use it to write the ExceptionInterceptor
, as shown in the following code block:
@Component public class ExceptionInterceptor implements ServerInterceptor {   @Override   public <RQT, RST> ServerCall.Listener<RQT> interceptCall(          ServerCall<RQT, RST> serverCall, Metadata metadata,          ServerCallHandler<RQT, RST> serverCallHandler) {      ServerCall.Listener...