liupeng 4 years ago
parent
commit
c821c2f68f

+ 0 - 41
code/sapparent/sapcms/src/main/java/org/fouram/controller/ControllerExceptionHandler.java

@@ -1,41 +0,0 @@
-package org.fouram.controller;
-
-import org.fouram.core.base.model.PageData;
-import org.fouram.core.util.AppUtil;
-import org.fouram.core.util.AppUtil.ResultConstant;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import lombok.extern.slf4j.Slf4j;
-import me.chanjar.weixin.common.error.WxErrorException;
-
-/**
- * @author Liup
- */
-@Slf4j
-@ControllerAdvice
-public class ControllerExceptionHandler {
-
-	/**
-	 * 异常处理
-	 */
-	@ResponseBody
-	@ExceptionHandler(Throwable.class)
-	public PageData exceptionHandler(Throwable ex) {
-		log.error(getExceptionAllInformation(ex));
-		if (ex.getClass().getSimpleName().equals(WxErrorException.class.getSimpleName())) {
-			return AppUtil.error(ex.getMessage());
-		}
-		return AppUtil.error(ResultConstant.WEB_ERR_MSG);
-	}
-
-	private static String getExceptionAllInformation(Throwable e) {
-		String sOut = e.toString() + "\r\n";
-		StackTraceElement[] trace = e.getStackTrace();
-		for (StackTraceElement s : trace) {
-			sOut += "\tat " + s + "\r\n";
-		}
-		return sOut;
-	}
-}

+ 4 - 6
code/sapparent/sapservice/src/main/java/org/fouram/core/base/exception/ControllerExceptionHandler.java

@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
 
 /**
  * @author Liup
@@ -22,16 +23,13 @@ public class ControllerExceptionHandler {
 	@ResponseBody
 	@ExceptionHandler(Throwable.class)
 	public PageData exceptionHandler(Throwable ex) {
-		if (!isPromptException(ex)) {
-			log.error(getExceptionAllInformation(ex));
+		log.error(getExceptionAllInformation(ex));
+		if (ex.getClass().getSimpleName().equals(WxErrorException.class.getSimpleName())) {
+			return AppUtil.error(ex.getMessage());
 		}
 		return AppUtil.error(ResultConstant.WEB_ERR_MSG);
 	}
 
-	private boolean isPromptException(Throwable ex) {
-		return "com.chuwa.core.exception.PromptException".equals(ex.getClass().getName());
-	}
-
 	private static String getExceptionAllInformation(Throwable e) {
 		String sOut = e.toString() + "\r\n";
 		StackTraceElement[] trace = e.getStackTrace();