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(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(ServerCall<?,?> serverCall,
Throwable throwable) |
protected Metadata |
resolveMetadata(Object mappedReturnType) |
protected Status |
resolveStatus(Object mappedReturnType) |
public GrpcAdviceExceptionHandler(GrpcExceptionHandlerMethodResolver grpcExceptionHandlerMethodResolver)
GrpcAdvice
powered GrpcExceptionHandler
.grpcExceptionHandlerMethodResolver
- The method resolver to use.public void handleError(ServerCall<?,?> serverCall, Throwable error)
GrpcExceptionResponseHandler
Status
.handleError
in interface GrpcExceptionResponseHandler
serverCall
- The server call used to send the response status.error
- The error to handle.protected void handleThrownExceptionByImplementation(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