Commit a4a84d40 authored by Junling Bu's avatar Junling Bu
Browse files

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

parent c88af083
package org.linlinjava.litemall.core.config; package org.linlinjava.litemall.core.config;
import org.linlinjava.litemall.core.util.ResponseUtil; 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.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
...@@ -17,11 +18,17 @@ public class GlobalExceptionHandler { ...@@ -17,11 +18,17 @@ public class GlobalExceptionHandler {
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
} }
@ExceptionHandler(HttpMessageNotReadableException.class)
@ResponseBody
public Object httpMessageNotReadableHandler(HttpMessageNotReadableException e){
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
@ResponseBody @ResponseBody
public Object exceptionHandler(Exception e){ public Object exceptionHandler(Exception e){
e.printStackTrace(); e.printStackTrace();
return ResponseUtil.serious(); return ResponseUtil.serious();
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment