Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-zx-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
项目统一框架
一体化_户用光伏项目代码
amos-boot-zx-biz
Commits
f7102990
Commit
f7102990
authored
Jul 01, 2024
by
wujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交默认异常配置
parent
cbec0fa5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
10 deletions
+16
-10
GlobalExceptionHandler.java
...s/boot/module/hygf/api/config/GlobalExceptionHandler.java
+15
-10
application-dev.properties
...le-hygf-biz/src/main/resources/application-dev.properties
+1
-0
No files found.
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/config/GlobalExceptionHandler.java
View file @
f7102990
...
...
@@ -29,9 +29,9 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Primary
public
class
GlobalExceptionHandler
{
@Value
(
"${exception.debug
}"
)
private
boolean
debug
;
@Value
(
"${exception.debug:false
}"
)
private
boolean
debug
;
/**
* 校验异常统一拦截地方
...
...
@@ -48,13 +48,18 @@ public class GlobalExceptionHandler {
response
.
setStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
response
.
setTraceId
(
RequestContext
.
getTraceId
());
response
.
setPath
(
request
.
getServletPath
());
// 获取异常的堆栈跟踪信息
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
e
.
printStackTrace
(
pw
);
String
stackTrace
=
sw
.
toString
();
response
.
setDevMessage
(
stackTrace
);
response
.
setMessage
(
stackTrace
);
if
(
debug
)
{
// 获取异常的堆栈跟踪信息
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
e
.
printStackTrace
(
pw
);
String
stackTrace
=
sw
.
toString
();
response
.
setDevMessage
(
stackTrace
);
response
.
setMessage
(
stackTrace
);
}
else
{
response
.
setDevMessage
(
e
.
getMessage
());
response
.
setMessage
(
e
.
getMessage
());
}
return
response
;
}
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/resources/application-dev.properties
View file @
f7102990
exception.debug
=
true
## DB properties:
spring.datasource.dynamic.primary
=
mysql-service
spring.datasource.mysql-service.driver-class-name
=
com.mysql.cj.jdbc.Driver
...
...
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