Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴学德
gdtel-gztel-school-center
Commits
92e3ca66
Commit
92e3ca66
authored
Mar 15, 2022
by
罗承锋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
统一异常处理
parent
5992c732
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
common/src/main/java/com/winsun/advice/ErrorControllerAdvice.java
+28
-0
No files found.
common/src/main/java/com/winsun/advice/ErrorControllerAdvice.java
0 → 100644
View file @
92e3ca66
package
com
.
winsun
.
advice
;
import
com.winsun.auth.core.common.model.ResponseData
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
/**
* @author chengfengluo
* @date 2022-03-15 11:08
*/
@Slf4j
@RestControllerAdvice
public
class
ErrorControllerAdvice
{
private
final
static
Integer
errorLength
=
20
;
@ExceptionHandler
(
Exception
.
class
)
public
ResponseData
<
String
>
allErrorHandler
(
Exception
e
)
{
String
message
=
e
.
getMessage
();
if
(
StringUtils
.
isNotBlank
(
message
)
&&
message
.
length
()
>
errorLength
)
{
return
ResponseData
.
error
(
"系统异常!"
);
}
else
{
return
ResponseData
.
error
(
e
.
getMessage
());
}
}
}
Write
Preview
Markdown
is supported
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