Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
a4a84d40
Commit
a4a84d40
authored
Jul 22, 2018
by
Junling Bu
Browse files
feat[litemall-core]: 添加一个异常处理器。
parent
c88af083
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-core/src/main/java/org/linlinjava/litemall/core/config/GlobalExceptionHandler.java
View file @
a4a84d40
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
();
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment