|
@@ -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;
|
|
|
- }
|
|
|
-}
|