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

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


The following commit(s) were added to refs/heads/dev-1.3.1-errorcode by this 
push:
     new 7f0a25187 [ISSUE-3399][linkis-engineplugin-python]errorcode code 
optimization (#3529)
7f0a25187 is described below

commit 7f0a251872fff59f0637cee56bb19d35196e9a71
Author: 成彬彬 <[email protected]>
AuthorDate: Tue Oct 18 10:38:23 2022 +0800

    [ISSUE-3399][linkis-engineplugin-python]errorcode code optimization (#3529)
---
 docs/errorcode/python-errorcode.md                 |  7 +++
 .../errorcode/LinkisPythonErrorCodeSummary.java    | 69 ++++++++++++++++++++++
 .../exception/NoSupportEngineException.scala       |  4 +-
 .../python/executor/PythonSession.scala            |  8 ++-
 .../python/factory/PythonEngineConnFactory.scala   |  3 +-
 5 files changed, 87 insertions(+), 4 deletions(-)

diff --git a/docs/errorcode/python-errorcode.md 
b/docs/errorcode/python-errorcode.md
new file mode 100644
index 000000000..8a4f84348
--- /dev/null
+++ b/docs/errorcode/python-errorcode.md
@@ -0,0 +1,7 @@
+## python errorcode
+
+| 模块名(服务名) | 错误码  | 描述 |enumeration name| Exception Class|
+| -------- | -------- | ----- |-----|-----|
+|python|41001| |PYTHON_EXECUTE_ERROR|LinkisPythonErrorCodeSummary|
+|python|60003|Pyspark process  has stopped, query failed!(Pyspark 
进程已停止,查询失败!)|PYSPARK_PROCESSS_STOPPED|LinkisPythonErrorCodeSummary|
+|python|400201|Invalid python session.(无效的 python 
会话.)|INVALID_PYTHON_SESSION|LinkisPythonErrorCodeSummary|
diff --git 
a/linkis-engineconn-plugins/python/src/main/java/org/apache/linkis/manager/engineplugin/python/errorcode/LinkisPythonErrorCodeSummary.java
 
b/linkis-engineconn-plugins/python/src/main/java/org/apache/linkis/manager/engineplugin/python/errorcode/LinkisPythonErrorCodeSummary.java
new file mode 100644
index 000000000..bb42d1acf
--- /dev/null
+++ 
b/linkis-engineconn-plugins/python/src/main/java/org/apache/linkis/manager/engineplugin/python/errorcode/LinkisPythonErrorCodeSummary.java
@@ -0,0 +1,69 @@
+/*
+ * 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.manager.engineplugin.python.errorcode;
+
+public enum LinkisPythonErrorCodeSummary {
+  PYTHON_EXECUTE_ERROR(41001, "", ""),
+  PYSPARK_PROCESSS_STOPPED(
+      60003,
+      "Pyspark process  has stopped, query failed!(Pyspark 进程已停止,查询失败!)",
+      "Pyspark process  has stopped, query failed!(Pyspark 进程已停止,查询失败!)"),
+  INVALID_PYTHON_SESSION(
+      400201, "Invalid python session.(无效的 python 会话.)", "Invalid python 
session.(无效的 python 会话.)");
+  /** 错误码 */
+  private int errorCode;
+  /** 错误描述 */
+  private String errorDesc;
+  /** 错误可能出现的原因 */
+  private String comment;
+
+  LinkisPythonErrorCodeSummary(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-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/exception/NoSupportEngineException.scala
 
b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/exception/NoSupportEngineException.scala
index 0fef91a94..119b4d473 100644
--- 
a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/exception/NoSupportEngineException.scala
+++ 
b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/exception/NoSupportEngineException.scala
@@ -18,7 +18,9 @@
 package org.apache.linkis.manager.engineplugin.python.exception
 
 import org.apache.linkis.common.exception.ErrorException
+import 
org.apache.linkis.manager.engineplugin.python.errorcode.LinkisPythonErrorCodeSummary.INVALID_PYTHON_SESSION
 
 class NoSupportEngineException(errCode: Int, desc: String) extends 
ErrorException(errCode, desc)
 
-case class PythonSessionStartFailedExeception(desc: String) extends 
ErrorException(400201, desc)
+case class PythonSessionStartFailedExeception(desc: String)
+    extends ErrorException(INVALID_PYTHON_SESSION.getErrorCode, desc)
diff --git 
a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonSession.scala
 
b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonSession.scala
index 4e6d83d43..8660b4107 100644
--- 
a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonSession.scala
+++ 
b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonSession.scala
@@ -22,6 +22,7 @@ import 
org.apache.linkis.engineconn.computation.executor.execute.EngineExecution
 import org.apache.linkis.engineconn.computation.executor.rs.RsOutputStream
 import org.apache.linkis.engineconn.launch.EngineConnServer
 import 
org.apache.linkis.manager.engineplugin.python.conf.PythonEngineConfiguration
+import 
org.apache.linkis.manager.engineplugin.python.errorcode.LinkisPythonErrorCodeSummary._
 import org.apache.linkis.manager.engineplugin.python.exception.{
   ExecuteException,
   PythonExecuteError
@@ -138,7 +139,10 @@ class PythonSession extends Logging {
       Utils.tryFinally({
         if (promise != null && !promise.isCompleted) {
           promise.failure(
-            new ExecuteException(60003, "Pyspark process  has stopped, query 
failed!")
+            new ExecuteException(
+              PYSPARK_PROCESSS_STOPPED.getErrorCode,
+              PYSPARK_PROCESSS_STOPPED.getErrorDesc
+            )
           )
         }
       }) {
@@ -226,7 +230,7 @@ class PythonSession extends Logging {
         close
         null
       } else {
-        promise.failure(new PythonExecuteError(41001, out))
+        promise.failure(new 
PythonExecuteError(PYTHON_EXECUTE_ERROR.getErrorCode, out))
       }
     }
   }
diff --git 
a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/factory/PythonEngineConnFactory.scala
 
b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/factory/PythonEngineConnFactory.scala
index 337308099..1880c3bc6 100644
--- 
a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/factory/PythonEngineConnFactory.scala
+++ 
b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/factory/PythonEngineConnFactory.scala
@@ -23,6 +23,7 @@ import 
org.apache.linkis.engineconn.common.engineconn.{DefaultEngineConn, Engine
 import 
org.apache.linkis.engineconn.computation.executor.creation.ComputationSingleExecutorEngineConnFactory
 import org.apache.linkis.engineconn.executor.entity.LabelExecutor
 import 
org.apache.linkis.manager.engineplugin.python.conf.PythonEngineConfiguration
+import 
org.apache.linkis.manager.engineplugin.python.errorcode.LinkisPythonErrorCodeSummary.INVALID_PYTHON_SESSION
 import 
org.apache.linkis.manager.engineplugin.python.exception.PythonSessionStartFailedExeception
 import org.apache.linkis.manager.engineplugin.python.executor.{
   PythonEngineConnExecutor,
@@ -47,7 +48,7 @@ class PythonEngineConnFactory extends 
ComputationSingleExecutorEngineConnFactory
           PythonEngineConfiguration.PYTHON_CONSOLE_OUTPUT_LINE_LIMIT.getValue
         )
       case _ =>
-        throw PythonSessionStartFailedExeception("Invalid python session.")
+        throw 
PythonSessionStartFailedExeception(INVALID_PYTHON_SESSION.getErrorDesc)
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to