|
@@ -2,26 +2,28 @@ package com.jpsoft.picc.advice;
|
|
|
|
|
|
import com.jpsoft.picc.exception.ApiException;
|
|
|
import com.jpsoft.picc.modules.common.dto.MessageResult;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
+@Slf4j
|
|
|
@ControllerAdvice
|
|
|
public class GlobalExceptionHandler {
|
|
|
/**
|
|
|
* 如果针对Exception.class 有可能把非ajax都返回json
|
|
|
- * @param e
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@ExceptionHandler(value = Exception.class)
|
|
|
- public MessageResult<String> handle(Exception e) {
|
|
|
+ public MessageResult<String> handle(Exception ex) {
|
|
|
//这里返回的类型不需要与抛异常的方法一致
|
|
|
MessageResult<String> messageResult = new MessageResult<>();
|
|
|
messageResult.setResult(false);
|
|
|
- messageResult.setMessage(e.getMessage());
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
|
return messageResult;
|
|
|
-// return e.getMessage();
|
|
|
}
|
|
|
}
|