Class GrpcAdviceExceptionHandler

java.lang.Object
net.devh.boot.grpc.server.advice.GrpcAdviceExceptionHandler
All Implemented Interfaces:
GrpcExceptionResponseHandler

public class GrpcAdviceExceptionHandler extends Object implements GrpcExceptionResponseHandler
As part of @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.

See Also:
  • Constructor Details

  • Method Details

    • handleError

      public void handleError(ServerCall<?,?> serverCall, Throwable error)
      Description copied from interface: GrpcExceptionResponseHandler
      Handles an exception by closing the call with an appropriate Status.
      Specified by:
      handleError in interface GrpcExceptionResponseHandler
      Parameters:
      serverCall - The server call used to send the response status.
      error - The error to handle.
    • resolveStatus

      protected Status resolveStatus(Object mappedReturnType)
    • resolveMetadata

      protected Metadata resolveMetadata(Object mappedReturnType)
    • handleThrownExceptionByImplementation

      protected void handleThrownExceptionByImplementation(ServerCall<?,?> serverCall, Throwable throwable)
    • handleThrownException

      @Nullable protected Object handleThrownException(Throwable exception) throws Throwable
      Given an exception, a lookup is performed to retrieve mapped method.
      In case of successful returned method, and matching exception parameter type for given exception, the exception is handed over to retrieved method. Retrieved method is then being invoked.
      Parameters:
      exception - exception to search for
      Returns:
      result of invoked mapped method to given exception
      Throws:
      Throwable - rethrows exception if no mapping existent or exceptions raised by implementation