You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/09/20 06:45:46 UTC

[incubator-linkis] branch dev-1.3.1 updated: [linkis-httpclient] errorcode optimization (#3461)

This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new eac35cca0 [linkis-httpclient] errorcode optimization (#3461)
eac35cca0 is described below

commit eac35cca0a3a491e242990ea4ab1aa56a097dd57
Author: 成彬彬 <10...@users.noreply.github.com>
AuthorDate: Tue Sep 20 14:45:41 2022 +0800

    [linkis-httpclient] errorcode optimization (#3461)
    
    * [linkis-httpclient] errorcode optimization
---
 docs/errorcode/linkis-httpclient-errorcode.md      | 15 ++++
 .../LinkisHttpclientErrorCodeSummary.java          | 86 ++++++++++++++++++++++
 .../httpclient/exception/DiscoveryException.scala  |  4 +-
 .../exception/HttpClientResultException.scala      |  4 +-
 .../exception/HttpClientRetryException.scala       |  4 +-
 .../exception/HttpMessageParseException.scala      |  9 ++-
 6 files changed, 117 insertions(+), 5 deletions(-)

diff --git a/docs/errorcode/linkis-httpclient-errorcode.md b/docs/errorcode/linkis-httpclient-errorcode.md
new file mode 100644
index 000000000..ee4236dc3
--- /dev/null
+++ b/docs/errorcode/linkis-httpclient-errorcode.md
@@ -0,0 +1,15 @@
+## linkis-httpclient errorcode
+
+![img.png](img.png)
+| 模块名(服务名) | 错误码  | 描述 | Exception Class|
+| -------- | -------- | ----- |-----|
+|linkis-httpclient|10901|connect to serverUrl failed! Reason: gateway server is unhealthy!(连接到 serverUrl 失败! 原因:网关服务器请求失败!)|DiscoveryException|
+|linkis-httpclient|10905|URL request failed!(URL 请求失败)|HttpClientResultException|
+|linkis-httpclient|10900|Discovery is not enable(未启用发现!)|HttpClientRetryException|
+|linkis-httpclient|10900|Discovery is not enable(未启用发现!)|HttpMessageParseException|
+|linkis-httpclient|10902|Not supported client method!(不支持客户端方法!)|HttpMessageParseException|
+
+
+
+
+
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/errorcode/LinkisHttpclientErrorCodeSummary.java b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/errorcode/LinkisHttpclientErrorCodeSummary.java
new file mode 100644
index 000000000..c5467d789
--- /dev/null
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/errorcode/LinkisHttpclientErrorCodeSummary.java
@@ -0,0 +1,86 @@
+/*
+ * 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.linkis.httpclient.errorcode;
+
+public enum LinkisHttpclientErrorCodeSummary {
+  CONNECT_TO_SERVERURL(
+          10901,
+          "connect to serverUrl failed! Reason: gateway server is unhealthy!(连接到 serverUrl 失败! 原因:网关服务器请求失败!)",
+          "connect to serverUrl failed! Reason: gateway server is unhealthy!(连接到 serverUrl 失败! 原因:网关服务器请求失败!)"),
+  REQUEST_FAILED_HTTP(
+          10905,
+          "URL request failed!(URL 请求失败)",
+          "URL request failed!(URL 请求失败)"),
+  RETRY_EXCEPTION(
+          10900,
+          "",
+          ""),
+  MESSAGE_PARSE_EXCEPTION(
+          10900,
+          "Discovery is not enable(未启用发现!)",
+          "Discovery is not enable(未启用发现!)"),
+
+  METHOD_NOT_SUPPORT_EXCEPTION(
+          10902,
+          "Not supported client method!(不支持客户端方法!)",
+          "Not supported client method!(不支持客户端方法!)");
+
+
+  /** error code(错误码) */
+  private int errorCode;
+  /** wrong description(错误描述 )*/
+  private String errorDesc;
+  /** Possible reasons for the error(错误可能出现的原因 )*/
+  private String comment;
+
+  LinkisHttpclientErrorCodeSummary(int errorCode, String errorDesc, String comment) {
+    this.errorCode = errorCode;
+    this.errorDesc = errorDesc;
+    this.comment = comment;
+  }
+
+  public int getErrorCode() {
+    return errorCode;
+  }
+
+  public void setErrorCode(int errorCode) {
+    this.errorCode = errorCode;
+  }
+
+  public String getErrorDesc() {
+    return errorDesc;
+  }
+
+  public void setErrorDesc(String errorDesc) {
+    this.errorDesc = errorDesc;
+  }
+
+  public String getComment() {
+    return comment;
+  }
+
+  public void setComment(String comment) {
+    this.comment = comment;
+  }
+
+
+  @Override
+  public String toString() {
+    return "errorCode: " + this.errorCode + ", errorDesc:" + this.errorDesc;
+  }
+}
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/DiscoveryException.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/DiscoveryException.scala
index 0c74e64b1..6c20f3857 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/DiscoveryException.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/DiscoveryException.scala
@@ -18,5 +18,7 @@
 package org.apache.linkis.httpclient.exception
 
 import org.apache.linkis.common.exception.ErrorException
+import org.apache.linkis.httpclient.errorcode.LinkisHttpclientErrorCodeSummary.CONNECT_TO_SERVERURL
 
-class DiscoveryException(errorDesc: String) extends ErrorException(10901, errorDesc)
+class DiscoveryException(errorDesc: String)
+    extends ErrorException(CONNECT_TO_SERVERURL.getErrorCode, errorDesc)
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpClientResultException.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpClientResultException.scala
index a87da1e05..d2688558d 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpClientResultException.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpClientResultException.scala
@@ -18,5 +18,7 @@
 package org.apache.linkis.httpclient.exception
 
 import org.apache.linkis.common.exception.ErrorException
+import org.apache.linkis.httpclient.errorcode.LinkisHttpclientErrorCodeSummary.REQUEST_FAILED_HTTP
 
-class HttpClientResultException(errorDesc: String) extends ErrorException(10905, errorDesc)
+class HttpClientResultException(errorDesc: String)
+    extends ErrorException(REQUEST_FAILED_HTTP.getErrorCode, errorDesc)
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpClientRetryException.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpClientRetryException.scala
index 5a2c5c30a..253f69ba5 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpClientRetryException.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpClientRetryException.scala
@@ -18,8 +18,10 @@
 package org.apache.linkis.httpclient.exception
 
 import org.apache.linkis.common.exception.LinkisRetryException
+import org.apache.linkis.httpclient.errorcode.LinkisHttpclientErrorCodeSummary.RETRY_EXCEPTION
 
-class HttpClientRetryException(errorDesc: String) extends LinkisRetryException(10900, errorDesc) {
+class HttpClientRetryException(errorDesc: String)
+    extends LinkisRetryException(RETRY_EXCEPTION.getErrorCode, errorDesc) {
 
   def this(errorDesc: String, throwable: Throwable) = {
     this(errorDesc)
diff --git a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpMessageParseException.scala b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpMessageParseException.scala
index 3dab52bc1..1d2149e0f 100644
--- a/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpMessageParseException.scala
+++ b/linkis-commons/linkis-httpclient/src/main/scala/org/apache/linkis/httpclient/exception/HttpMessageParseException.scala
@@ -18,6 +18,11 @@
 package org.apache.linkis.httpclient.exception
 
 import org.apache.linkis.common.exception.ErrorException
+import org.apache.linkis.httpclient.errorcode.LinkisHttpclientErrorCodeSummary.MESSAGE_PARSE_EXCEPTION
+import org.apache.linkis.httpclient.errorcode.LinkisHttpclientErrorCodeSummary.METHOD_NOT_SUPPORT_EXCEPTION
 
-class HttpMessageParseException(errorDesc: String) extends ErrorException(10900, errorDesc)
-class HttpMethodNotSupportException(errorDesc: String) extends ErrorException(10902, errorDesc)
+class HttpMessageParseException(errorDesc: String)
+    extends ErrorException(MESSAGE_PARSE_EXCEPTION.getErrorCode, errorDesc)
+
+class HttpMethodNotSupportException(errorDesc: String)
+    extends ErrorException(METHOD_NOT_SUPPORT_EXCEPTION.getErrorCode, errorDesc)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org