yuqi1129 commented on code in PR #9761:
URL: https://github.com/apache/gravitino/pull/9761#discussion_r2736753538


##########
catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseExceptionConverter.java:
##########
@@ -18,8 +18,36 @@
  */
 package org.apache.gravitino.catalog.clickhouse.converter;
 
+import java.sql.SQLException;
 import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter;
+import org.apache.gravitino.exceptions.GravitinoRuntimeException;
+import org.apache.gravitino.exceptions.NoSuchSchemaException;
+import org.apache.gravitino.exceptions.NoSuchTableException;
+import org.apache.gravitino.exceptions.SchemaAlreadyExistsException;
+import org.apache.gravitino.exceptions.TableAlreadyExistsException;
 
 public class ClickHouseExceptionConverter extends JdbcExceptionConverter {
-  // Implement ClickHouse specific exception conversions if needed
+  static final int UNKNOWN_DATABASE = 81;
+  static final int DATABASE_ALREADY_EXISTS = 82;
+
+  static final int TABLE_ALREADY_EXISTS = 57;
+  static final int TABLE_IS_DROPPED = 218;
+
+  @SuppressWarnings("FormatStringAnnotation")
+  @Override
+  public GravitinoRuntimeException toGravitinoException(SQLException 
sqlException) {
+    int errorCode = sqlException.getErrorCode();
+    switch (errorCode) {
+      case DATABASE_ALREADY_EXISTS:
+        return new SchemaAlreadyExistsException(sqlException, 
sqlException.getMessage());
+      case TABLE_ALREADY_EXISTS:
+        return new TableAlreadyExistsException(sqlException, 
sqlException.getMessage());
+      case UNKNOWN_DATABASE:
+        return new NoSuchSchemaException(sqlException, 
sqlException.getMessage());
+      case TABLE_IS_DROPPED:
+        return new NoSuchTableException(sqlException, 
sqlException.getMessage());
+      default:
+        return new GravitinoRuntimeException(sqlException, 
sqlException.getMessage());

Review Comment:
   You are wrong. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to