public static ClickHouseException specify(String clickHouseMessage,Throwable cause,String host,int port){
  if (StringUtils.isEmpty(clickHouseMessage) && cause != null) {
    if (cause instanceof SocketTimeoutException)     return new ClickHouseException(ClickHouseErrorCode.TIMEOUT_EXCEEDED.code,cause,host,port);
 else     if (cause instanceof ConnectTimeoutException || cause instanceof ConnectException)     return new ClickHouseException(ClickHouseErrorCode.NETWORK_ERROR.code,cause,host,port);
 else     return new ClickHouseUnknownException(cause,host,port);
  }
  try {
    int code;
    if (clickHouseMessage.startsWith("Poco::Exception. Code: 1000, ")) {
      code=1000;
    }
 else {
      code=Integer.parseInt(clickHouseMessage.substring(clickHouseMessage.indexOf(' ') + 1,clickHouseMessage.indexOf(',')));
    }
    Throwable messageHolder=cause != null ? cause : new Throwable(clickHouseMessage);
    return new ClickHouseException(code,messageHolder,host,port);
  }
 catch (  Exception e) {
    log.error("Unsupported ClickHouse error format, please fix ClickHouseExceptionSpecifier, message: " + clickHouseMessage + ", error: "+ e.getMessage());
    return new ClickHouseUnknownException(clickHouseMessage,cause,host,port);
  }
}

public static ClickHouseException specify ( String clickHouseMessage , Throwable cause , String host , int port ) { if ( StringUtils . isEmpty ( clickHouseMessage ) && cause != null ) { if ( cause instanceof SocketTimeoutException ) return new ClickHouseException ( ClickHouseErrorCode . TIMEOUT_EXCEEDED . code , cause , host , port ) ; else if ( cause instanceof ConnectTimeoutException || cause instanceof ConnectException ) return new ClickHouseException ( ClickHouseErrorCode . NETWORK_ERROR . code , cause , host , port ) ; else return new ClickHouseUnknownException ( cause , host , port ) ; } try { int code ; if ( clickHouseMessage . startsWith ( "Poco::Exception. Code: 1000, " ) ) { code = 1000 ; } else { code = Integer . parseInt ( clickHouseMessage . substring ( clickHouseMessage . indexOf ( ' ' ) + 1 , clickHouseMessage . indexOf ( ',' ) ) ) ; } Throwable messageHolder = cause != null ? cause : new Throwable ( clickHouseMessage ) ; return new ClickHouseException ( code , messageHolder , host , port ) ; } catch ( Exception e ) { log . error ( "Unsupported ClickHouse error format, please fix ClickHouseExceptionSpecifier, message: " + clickHouseMessage + ", error: " + e . getMessage ( ) ) ; return new ClickHouseUnknownException ( clickHouseMessage , cause , host , port ) ; } }
here we expect the clickhouse error message to be of the following format : " code : 10 , e . displaytext ( ) = db : : exception : . . . " .
