Class ClickHouseException

java.lang.Object
java.lang.Throwable
java.lang.Exception
com.clickhouse.client.ClickHouseException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ClickHouseTransactionException

public class ClickHouseException extends Exception
Exception thrown from ClickHouse server. See full list at https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/ErrorCodes.cpp.
See Also:
  • Field Details

  • Constructor Details

    • ClickHouseException

      public ClickHouseException(int code, Throwable cause, ClickHouseNode server)
      Constructs an exception with cause.
      Parameters:
      code - error code
      cause - cause of the exception
      server - server
    • ClickHouseException

      public ClickHouseException(int code, String message, ClickHouseNode server)
      Constructs an exception without cause.
      Parameters:
      code - error code
      message - error message
      server - server
    • ClickHouseException

      protected ClickHouseException(int code, String message, Throwable cause)
      Constructs an exception.
      Parameters:
      code - error code
      message - error message
      cause - cause
  • Method Details

    • buildErrorMessage

      public static String buildErrorMessage(int code, String detail)
      Builds error message like "Code: <code>, <detail>".
      Parameters:
      code - error code
      detail - detail of the error
      Returns:
      non-null error message
    • forCancellation

      public static ClickHouseException forCancellation(Exception e, ClickHouseNode server)
      Creates an exception for cancellation.
      Parameters:
      e - exception
      server - server
      Returns:
      ClickHouseException
    • isConnectTimedOut

      public static boolean isConnectTimedOut(Throwable t)
      Checks if the given exception represents connection timeout error.
      Parameters:
      t - exception
      Returns:
      true if the exception represents connection timeout error; false otherwise
    • of

      public static ClickHouseException of(Throwable e, ClickHouseNode server)
      Creates an exception to encapsulate cause of the given exception.
      Parameters:
      e - exception
      server - server
      Returns:
      ClickHouseException
    • of

      public static ClickHouseException of(String message, ClickHouseNode server)
      Creates an exception to encapsulate the given error message.
      Parameters:
      message - error message
      server - server
      Returns:
      ClickHouseException
    • getErrorCode

      public int getErrorCode()
      Gets error code.
      Returns:
      error code