Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
gsc
/
gsc-vcp-web-facade
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 672f0018
authored
Dec 01, 2025
by
张富康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
GlobalExceptionHandler 修改异常打印信息
1 parent
6df0c809
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
src/main/java/com/gsc4cloud/gsc/facade/vpcweb/handler/GlobalExceptionHandler.java
src/main/java/com/gsc4cloud/gsc/facade/vpcweb/handler/GlobalExceptionHandler.java
View file @
672f001
...
@@ -55,7 +55,7 @@ public class GlobalExceptionHandler {
...
@@ -55,7 +55,7 @@ public class GlobalExceptionHandler {
private
String
EXCEPTION_PUSH_URL
;
private
String
EXCEPTION_PUSH_URL
;
@Value
(
"${pushExceptionFlag: true}"
)
@Value
(
"${pushExceptionFlag: true}"
)
private
Boolean
pushExceptionFlag
;
private
Boolean
pushExceptionFlag
;
@Value
(
"${excludeExceptions:
org.springframework.web.servlet.resource.NoResourceFoundException
}"
)
@Value
(
"${excludeExceptions:}"
)
private
List
<
String
>
excludeExceptionList
;
private
List
<
String
>
excludeExceptionList
;
@Resource
@Resource
private
Environment
environment
;
private
Environment
environment
;
...
@@ -144,18 +144,21 @@ public class GlobalExceptionHandler {
...
@@ -144,18 +144,21 @@ public class GlobalExceptionHandler {
*/
*/
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Exception
.
class
)
public
ResponseEntity
<
R
<?>>
handleException
(
Exception
e
,
HttpServletRequest
request
)
{
public
ResponseEntity
<
R
<?>>
handleException
(
Exception
e
,
HttpServletRequest
request
)
{
excludeExceptionList
.
add
(
"org.springframework.web.servlet.resource.NoResourceFoundException"
);
String
typeName
=
e
.
getClass
().
getTypeName
();
boolean
checkException
=
ObjectUtil
.
isNotEmpty
(
excludeExceptionList
)
&&
excludeExceptionList
.
contains
(
typeName
);
if
(!
checkException
)
{
log
.
error
(
"系统异常: "
,
e
);
log
.
error
(
"系统异常: "
,
e
);
}
ResponseEntity
<
R
<?>>
body
=
ResponseEntity
ResponseEntity
<
R
<?>>
body
=
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
status
(
HttpStatus
.
OK
)
.
body
(
R
.
restResult
(
null
,
ErrorCodeEnum
.
SYSTEM_ERROR
.
getCode
(),
ErrorCodeEnum
.
SYSTEM_ERROR
.
getMessage
()));
.
body
(
R
.
restResult
(
null
,
ErrorCodeEnum
.
SYSTEM_ERROR
.
getCode
(),
ErrorCodeEnum
.
SYSTEM_ERROR
.
getMessage
()));
if
(!
pushExceptionFlag
||
StrUtil
.
isNotBlank
(
environment
.
getProperty
(
LOCAL_DEBUG
)))
{
if
(!
pushExceptionFlag
||
StrUtil
.
isNotBlank
(
environment
.
getProperty
(
LOCAL_DEBUG
)))
{
return
body
;
return
body
;
}
}
String
typeName
=
e
.
getClass
().
getTypeName
();
// 可以在nacos进行配置哪些异常不发送信息 哪些异常发送信息
// 可以在nacos进行配置哪些异常不发送信息 哪些异常发送信息
// 判断异常类型是否在list中
// 判断异常类型是否在list中
excludeExceptionList
.
add
(
"org.springframework.web.servlet.resource.NoResourceFoundException"
);
if
(
checkException
)
{
if
(
ObjectUtil
.
isNotEmpty
(
excludeExceptionList
)
&&
excludeExceptionList
.
contains
(
typeName
))
{
return
body
;
return
body
;
}
}
ExceptionPushRequest
exceptionPushRequest
=
new
ExceptionPushRequest
();
ExceptionPushRequest
exceptionPushRequest
=
new
ExceptionPushRequest
();
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment