Interface JsonRpcExceptionHandler

All Superinterfaces:
ServerLifecycle
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface JsonRpcExceptionHandler extends ServerLifecycle
An exception handler that can be registered to map exceptions thrown in method handlers to JsonRpcErrors.
  • Method Details

    • handle

      Optional<JsonRpcError> handle(JsonRpcRequest req, JsonRpcResponse res, Throwable throwable) throws Exception
      Handler for exceptions thrown in JSON-RPC method handlers.
      Parameters:
      req - the server request
      res - the server response
      throwable - the throwable thrown by the method handler
      Returns:
      an optional JSON-RPC error to be returned to the client. If the returned optional is empty, then an error with code JsonRpcError.INTERNAL_ERROR is sent instead.
      Throws:
      Exception - if an unexpected condition is found