TyrantLucifer commented on code in PR #3593: URL: https://github.com/apache/incubator-seatunnel/pull/3593#discussion_r1035491818
########## seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/exception/StarRocksConnectorErrorCode.java: ########## @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.seatunnel.connectors.seatunnel.starrocks.exception; + +import org.apache.seatunnel.common.exception.SeaTunnelErrorCode; + +public enum StarRocksConnectorErrorCode implements SeaTunnelErrorCode { + FLUSH_DATA_FAILED("STARROCKS-01", "Flush batch data to sink connector failed"), Review Comment: Remove this useless error code. Use `CommonErrorCode.FLUST_DATA_FAILED` ########## seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/exception/StarRocksConnectorErrorCode.java: ########## @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.seatunnel.connectors.seatunnel.starrocks.exception; + +import org.apache.seatunnel.common.exception.SeaTunnelErrorCode; + +public enum StarRocksConnectorErrorCode implements SeaTunnelErrorCode { + FLUSH_DATA_FAILED("STARROCKS-01", "Flush batch data to sink connector failed"), + WRITE_RECORDS_FAILED("STARROCKS-02", "Writing records to StarRocks failed."); + private final String code; + private final String description; + + StarRocksConnectorErrorCode(String code, String description) { + this.code = code; + this.description = description; + } + + @Override + public String getCode() { + return null; + } + + @Override + public String getDescription() { + return null; Review Comment: return decription ########## seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/exception/StarRocksConnectorErrorCode.java: ########## @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.seatunnel.connectors.seatunnel.starrocks.exception; + +import org.apache.seatunnel.common.exception.SeaTunnelErrorCode; + +public enum StarRocksConnectorErrorCode implements SeaTunnelErrorCode { + FLUSH_DATA_FAILED("STARROCKS-01", "Flush batch data to sink connector failed"), + WRITE_RECORDS_FAILED("STARROCKS-02", "Writing records to StarRocks failed."); + private final String code; + private final String description; + + StarRocksConnectorErrorCode(String code, String description) { + this.code = code; + this.description = description; + } + + @Override + public String getCode() { + return null; Review Comment: return code ########## seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/client/StarRocksSinkManager.java: ########## @@ -116,10 +118,10 @@ public synchronized void flush() throws IOException { } catch (Exception e) { log.warn("Writing records to StarRocks failed, retry times = {}", i, e); if (i >= sinkConfig.getMaxRetries()) { - throw new IOException("Writing records to StarRocks failed.", e); + throw new StarRocksConnectorException(StarRocksConnectorErrorCode.WRITE_RECORDS_FAILED, e); Review Comment: throw new StarRocksConnectorException(StarRocksConnectorErrorCode.WRITE_RECORDS_FAILED, errorMessage, e); ########## seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/client/StarRocksSinkManager.java: ########## @@ -143,7 +144,7 @@ public synchronized void flush() throws IOException { private void checkFlushException() { if (flushException != null) { - throw new RuntimeException("Writing records to StarRocks failed.", flushException); + throw new StarRocksConnectorException(StarRocksConnectorErrorCode.FLUSH_DATA_FAILED, flushException); Review Comment: throw new StarRocksConnectorException(StarRocksConnectorErrorCode.FLUSH_DATA_FAILED, errorMessage, flushException) -- 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]
