public class GrpcAdviceExceptionHandler extends Object implements GrpcExceptionResponseHandler
@GrpcAdvice, when a thrown exception is caught during gRPC calls (via global
interceptor GrpcExceptionInterceptor), then this thrown exception is being handled. The
GrpcExceptionHandlerMethodResolver provides a mapping for exceptions and their respective handler methods.
The response is derived from methods annotated with GrpcExceptionHandler inside GrpcAdvice beans.
| Constructor and Description |
|---|
GrpcAdviceExceptionHandler(GrpcExceptionHandlerMethodResolver grpcExceptionHandlerMethodResolver)
Creates a new
GrpcAdvice powered GrpcExceptionHandler. |
| Modifier and Type | Method and Description |
|---|---|
void |
handleError(io.grpc.ServerCall<?,?> serverCall,
Throwable error)
Handles an exception by closing the call with an appropriate
Status. |
protected Object |
handleThrownException(Throwable exception)
Given an exception, a lookup is performed to retrieve mapped method.
|
protected void |
handleThrownExceptionByImplementation(io.grpc.ServerCall<?,?> serverCall,
Throwable throwable) |
protected io.grpc.Metadata |
resolveMetadata(Object mappedReturnType) |
protected io.grpc.Status |
resolveStatus(Object mappedReturnType) |
public GrpcAdviceExceptionHandler(GrpcExceptionHandlerMethodResolver grpcExceptionHandlerMethodResolver)
GrpcAdvice powered GrpcExceptionHandler.grpcExceptionHandlerMethodResolver - The method resolver to use.public void handleError(io.grpc.ServerCall<?,?> serverCall,
Throwable error)
GrpcExceptionResponseHandlerStatus.handleError in interface GrpcExceptionResponseHandlerserverCall - The server call used to send the response status.error - The error to handle.protected io.grpc.Status resolveStatus(Object mappedReturnType)
protected io.grpc.Metadata resolveMetadata(Object mappedReturnType)
protected void handleThrownExceptionByImplementation(io.grpc.ServerCall<?,?> serverCall,
Throwable throwable)
@Nullable protected Object handleThrownException(Throwable exception) throws Throwable
exception - exception to search forThrowable - rethrows exception if no mapping existent or exceptions raised by implementation