feat[litemall-core]: 添加一个异常处理器。

This commit is contained in:
Junling Bu
2018-07-22 21:30:01 +08:00
parent c88af0833b
commit a4a84d4045

View File

@@ -1,6 +1,7 @@
package org.linlinjava.litemall.core.config;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -17,11 +18,17 @@ public class GlobalExceptionHandler {
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(HttpMessageNotReadableException.class)
@ResponseBody
public Object httpMessageNotReadableHandler(HttpMessageNotReadableException e){
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(Exception.class)
@ResponseBody
public Object exceptionHandler(Exception e){
e.printStackTrace();
return ResponseUtil.serious();
}
}