Interface JsonRpcError


public interface JsonRpcError
A representation of a JSON-RPC error.
  • Field Details

    • PARSE_ERROR

      static final int PARSE_ERROR
      Invalid JSON was received by the server.
      See Also:
    • INVALID_REQUEST

      static final int INVALID_REQUEST
      The JSON sent is not a valid Request object.
      See Also:
    • METHOD_NOT_FOUND

      static final int METHOD_NOT_FOUND
      The method does not exist or is not available.
      See Also:
    • INVALID_PARAMS

      static final int INVALID_PARAMS
      Invalid method parameter(s).
      See Also:
    • INTERNAL_ERROR

      static final int INTERNAL_ERROR
      Internal JSON-RPC error.
      See Also:
  • Method Details

    • create

      static JsonRpcError create(JsonObject error)
      Create an instance from a JSON object.
      Parameters:
      error - the object
      Returns:
      a new instance of this class
    • create

      static JsonRpcError create(int code, String message)
      Create an instance from a code and a message.
      Parameters:
      code - the error code
      message - the message
      Returns:
      a new instance of this class
    • create

      static JsonRpcError create(int code, String message, JsonValue data)
      Create an instance from a code, a message and data.
      Parameters:
      code - the error code
      message - the message
      data - the associated data
      Returns:
      a new instance of this class
    • code

      int code()
      Get the code for this error.
      Returns:
      the code
    • message

      String message()
      Get the message for this error.
      Returns:
      the message
    • data

      Get the data associated with this error, if defined.
      Returns:
      optional data
    • dataAs

      <T> Optional<T> dataAs(Class<T> type)
      Get the data associated with this error as an object, if defined. This method will use JSONB for binding.
      Type Parameters:
      T - the bean type
      Parameters:
      type - the bean class
      Returns:
      optional data
      Throws:
      ClassCastException - if the data is not a JSON object
      JsonbException - if an error occurs during mapping
    • asJsonObject

      JsonObject asJsonObject()
      Access the error as a JSON object.
      Returns:
      a JSON object