Class GrpcAdviceExceptionHandler
java.lang.Object
org.springframework.grpc.server.advice.GrpcAdviceExceptionHandler
- All Implemented Interfaces:
GrpcExceptionHandler
Handles exceptions by delegating to
@GrpcExceptionHandler
methods in @GrpcAdvice beans.- Author:
- Oleksandr Shevchenko
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGrpcAdviceExceptionHandler(GrpcExceptionHandlerMethodResolver grpcExceptionHandlerMethodResolver) Create a new instance. -
Method Summary
Modifier and TypeMethodDescription@Nullable io.grpc.StatusExceptionhandleException(Throwable exception) Handle the given exception that occurred during gRPC server-side processing.protected @Nullable ObjecthandleThrownException(Throwable exception) Look up and invoke the handler method for the given exception.protected io.grpc.MetadataresolveMetadata(Object mappedReturnType) Resolve the metadata from the handler's return value.protected io.grpc.StatusresolveStatus(Object mappedReturnType) Resolve the gRPC status from the handler's return value.
-
Constructor Details
-
GrpcAdviceExceptionHandler
public GrpcAdviceExceptionHandler(GrpcExceptionHandlerMethodResolver grpcExceptionHandlerMethodResolver) Create a new instance.- Parameters:
grpcExceptionHandlerMethodResolver- the method resolver to use
-
-
Method Details
-
handleException
Description copied from interface:GrpcExceptionHandlerHandle the given exception that occurred during gRPC server-side processing.- Specified by:
handleExceptionin interfaceGrpcExceptionHandler- Parameters:
exception- the exception to handle- Returns:
- the status to return to the client, or
nullif the exception cannot be classified
-
resolveStatus
Resolve the gRPC status from the handler's return value.- Parameters:
mappedReturnType- the handler return value- Returns:
- the resolved status
-
resolveMetadata
Resolve the metadata from the handler's return value.- Parameters:
mappedReturnType- the handler return value- Returns:
- the resolved metadata, or empty metadata
-
handleThrownException
Look up and invoke the handler method for the given exception.- Parameters:
exception- the exception to handle- Returns:
- the handler result, or
nullif no handler is mapped - Throws:
Throwable- if the handler throws an exception
-