From 426cd61c707f13a471b56330b3ba7b588b6cb245 Mon Sep 17 00:00:00 2001
From: fujunling <2984387807@qq.com>
Date: 星期四, 15 六月 2023 18:11:58 +0800
Subject: [PATCH] Merge branch 'master' of http://dev.vci-tech.com:1065/r/ubcs

---
 Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/exception/VciBaseException.java |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/exception/VciBaseException.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/exception/VciBaseException.java
index eadbff9..16cfcb6 100644
--- a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/exception/VciBaseException.java
+++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/exception/VciBaseException.java
@@ -9,10 +9,14 @@
 import com.vci.ubcs.starter.web.util.MessageUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springblade.core.log.exception.ServiceException;
+import org.springframework.web.server.ServerErrorException;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.text.MessageFormat;
 
-public class VciBaseException extends RuntimeException {
+public class VciBaseException extends ServiceException {
 	private Logger log = LoggerFactory.getLogger(this.getClass());
 	public static final String paramNull = "com.vci.base.paramNull";
 	public static final String fieldValueRepeat = "com.vci.base.fieldValueRepeat";
@@ -29,16 +33,18 @@
 	private Object[] objs = new Object[0];
 
 	public VciBaseException(String code) {
+		super(code);
 		this.code = code;
 	}
 
 	public VciBaseException(String code, Object[] objs) {
+		super(code);
 		this.code = code;
 		this.objs = objs;
 	}
 
 	public VciBaseException(String code, Object[] objs, Throwable e) {
-		super(e);
+		super(code);
 		this.code = code;
 		this.objs = objs;
 	}
@@ -72,6 +78,36 @@
 		}
 	}
 
+	/**
+	 * 鑾峰彇寮傚父淇℃伅
+	 * @param e 寮傚父瀵硅薄
+	 * @return 寮傚父瀵硅薄涓婄殑鎵�鏈夊唴瀹�
+	 */
+	public static String getErrorMsgByE(Throwable e){
+		if(e == null){
+			return "鏈煡閿欒";
+		}
+		if( e.getClass()!= null && e.getClass().getSuperclass()!= null &&
+			(e.getClass().getSuperclass().equals(RuntimeException.class)
+				|| e.getClass().getSuperclass().getName().endsWith(".VciBaseException")
+				|| e.getClass().getName().endsWith(".VciBaseException"))){
+			//璇存槑鏄垜浠嚜瀹氫箟鐨勫紓甯哥被
+			try {
+				Method errorMethod = e.getClass().getMethod("getErrorMsg");
+				if(errorMethod != null ){
+					return (String)errorMethod.invoke(e);
+				}
+			} catch (NoSuchMethodException e1) {
+				return e.getMessage();
+			} catch (IllegalAccessException e1) {
+				return e.getMessage();
+			} catch (InvocationTargetException e1) {
+				return e.getMessage();
+			}
+		}
+		return e.getMessage();
+	}
+
 	@Override
 	public String getMessage() {
 		return this.getCode() + "," + this.getErrorMsg();

--
Gitblit v1.9.3