Class SchemaRegistryException

All Implemented Interfaces:
Serializable

public final class SchemaRegistryException extends RuntimeException
Reports a schema registry transport, status, or response error.

Thrown by KrabkaSchemaRegistryClient when a request cannot be sent, the registry answers with a non-2xx status, or the response body cannot be parsed. Because the client is asynchronous, the exception usually arrives as the cause of a CompletionException.

Example

client.latest("orders-value").exceptionally(error -> {
    if (error.getCause() instanceof SchemaRegistryException registry
            && registry.statusCode() == 404) {
        return null; // subject does not exist yet
    }
    throw new CompletionException(error);
});
See Also:
  • Constructor Details

    • SchemaRegistryException

      public SchemaRegistryException(String message)
      Creates an exception for a malformed request or response.
      Parameters:
      message - a description of the failure
    • SchemaRegistryException

      public SchemaRegistryException(String message, Throwable cause)
      Creates an exception for a transport or encoding failure.
      Parameters:
      message - a description of the failure
      cause - the underlying error
    • SchemaRegistryException

      public SchemaRegistryException(int statusCode, String body)
      Creates an exception for a non-2xx registry response.
      Parameters:
      statusCode - the HTTP status returned by the registry
      body - the response body, included in the message
  • Method Details

    • statusCode

      public int statusCode()
      Returns the HTTP status, or -1 for a transport or parsing error.
      Returns:
      the HTTP status code, or -1 when no status was received