|
@@ -1,41 +1,44 @@
|
|
|
-package org.fouram.core.base.exception;
|
|
|
-
|
|
|
-import org.fouram.core.base.model.PageData;
|
|
|
-import org.fouram.core.plugin.weixin.cp.util.WXCpMessageUtil;
|
|
|
-import org.fouram.core.util.AppUtil;
|
|
|
-import org.fouram.core.util.AppUtil.ResultConstant;
|
|
|
-import org.fouram.core.util.Tools;
|
|
|
-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) {
|
|
|
- // 提示不输出报错日志
|
|
|
- if (PromptException.class.getSimpleName().equals(ex.getClass().getSimpleName())) {
|
|
|
- return AppUtil.error(ex.getMessage());
|
|
|
- }
|
|
|
- String messageContent = Tools.getExceptionAllInfo(ex);
|
|
|
-// WXCpMessageUtil.sendAdminError(messageContent);
|
|
|
- log.error(messageContent);
|
|
|
- if (ex.getClass().getSimpleName().equals(WxErrorException.class.getSimpleName())) {
|
|
|
- WxErrorException wxErrorException = (WxErrorException) ex;
|
|
|
- return AppUtil.error(wxErrorException.getError().getErrorMsg());
|
|
|
- }
|
|
|
- return AppUtil.error(ResultConstant.WEB_ERR_MSG);
|
|
|
- }
|
|
|
+package org.fouram.core.base.exception;
|
|
|
+
|
|
|
+import org.fouram.constants.WebConstants;
|
|
|
+import org.fouram.core.base.model.PageData;
|
|
|
+import org.fouram.core.plugin.weixin.cp.util.WXCpMessageUtil;
|
|
|
+import org.fouram.core.util.AppUtil;
|
|
|
+import org.fouram.core.util.AppUtil.ResultConstant;
|
|
|
+import org.fouram.core.util.Tools;
|
|
|
+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) {
|
|
|
+ // 提示不输出报错日志
|
|
|
+ if (PromptException.class.getSimpleName().equals(ex.getClass().getSimpleName())) {
|
|
|
+ return AppUtil.error(ex.getMessage());
|
|
|
+ }
|
|
|
+ String messageContent = Tools.getExceptionAllInfo(ex);
|
|
|
+ if(WebConstants.isProduct()) {
|
|
|
+ WXCpMessageUtil.sendAdminError(messageContent);
|
|
|
+ }
|
|
|
+ log.error(messageContent);
|
|
|
+ if (ex.getClass().getSimpleName().equals(WxErrorException.class.getSimpleName())) {
|
|
|
+ WxErrorException wxErrorException = (WxErrorException) ex;
|
|
|
+ return AppUtil.error(wxErrorException.getError().getErrorMsg());
|
|
|
+ }
|
|
|
+ return AppUtil.error(ResultConstant.WEB_ERR_MSG);
|
|
|
+ }
|
|
|
}
|