Class GrpcExceptionHandlerInterceptor
java.lang.Object
org.springframework.grpc.server.exception.GrpcExceptionHandlerInterceptor
- All Implemented Interfaces:
io.grpc.ServerInterceptor
@Order(-2147483648)
public class GrpcExceptionHandlerInterceptor
extends Object
implements io.grpc.ServerInterceptor
A gRPC
ServerInterceptor that handles exceptions thrown during the processing
of gRPC calls. It intercepts the call and wraps the ServerCall.Listener with an
GrpcExceptionHandlerInterceptor.ExceptionHandlerListener that catches exceptions in onMessage and
onHalfClose methods, and delegates the exception handling to the provided
GrpcExceptionHandler.
A fallback mechanism is used to return UNKNOWN in case the GrpcExceptionHandler
returns a null.
- Author:
- Dave Syer, Andrey Litvitski
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<ReqT,RespT>
io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT, RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT, RespT> next) Intercepts a gRPC server call to handle exceptions.
-
Constructor Details
-
GrpcExceptionHandlerInterceptor
-
-
Method Details
-
interceptCall
public <ReqT,RespT> io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT, RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT, RespT> next) Intercepts a gRPC server call to handle exceptions.- Specified by:
interceptCallin interfaceio.grpc.ServerInterceptor- Type Parameters:
ReqT- the type of the request messageRespT- the type of the response message- Parameters:
call- the server call objectheaders- the metadata headers for the callnext- the next server call handler in the interceptor chain- Returns:
- a listener for the request messages
-