Interface ExceptionHandler<E extends Throwable,T>

Type Parameters:
E - the type of exception to handle
T - the type of result returned

@SPI(scope=FRAMEWORK) public interface ExceptionHandler<E extends Throwable,T>
Interface for customize exception handling.
  • Method Details

    • resolveLogLevel

      default Level resolveLogLevel(E throwable)
      Resolves the log level for a given throwable.
      Parameters:
      throwable - the exception
      Returns:
      the log level, or null to ignore this extension
    • resolveGrpcStatus

      default boolean resolveGrpcStatus(E throwable, HttpHeaders headers, RequestMetadata metadata, MethodDescriptor descriptor)
      Resolves the gRPC status for a given throwable.
      Parameters:
      throwable - the exception
      headers - the response headers
      metadata - the request metadata, may be null
      descriptor - the method descriptor, may be null
    • handle

      default T handle(E throwable, RequestMetadata metadata, MethodDescriptor descriptor)
      Handle the exception and return a result.
      Parameters:
      throwable - the exception
      metadata - the request metadata, may be null
      descriptor - the method descriptor, may be null
      Returns:
      a result of type T, or null to ignore this extension
    • handleGrpc

      default T handleGrpc(E throwable, RequestMetadata metadata, MethodDescriptor descriptor)
      Handles the exception and return a result for gRPC protocol.
      Parameters:
      throwable - the exception
      metadata - the request metadata, may be null
      descriptor - the method descriptor, may be null
      Returns:
      a result of type T, or null to ignore this extension