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
Eladmin
Commits
5ece3a3d
Commit
5ece3a3d
authored
May 24, 2019
by
zhuon
Browse files
修复bug:重新catch再throw new Exception会导致部分堆栈信息丢失
parent
90c2bf90
Changes
2
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java
View file @
5ece3a3d
...
@@ -26,8 +26,8 @@ public class GlobalExceptionHandler {
...
@@ -26,8 +26,8 @@ public class GlobalExceptionHandler {
* @param e
* @param e
* @return
* @return
*/
*/
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Throwable
.
class
)
public
ResponseEntity
handleException
(
Exception
e
){
public
ResponseEntity
handleException
(
Throwable
e
){
// 打印堆栈信息
// 打印堆栈信息
log
.
error
(
ThrowableUtil
.
getStackTrace
(
e
));
log
.
error
(
ThrowableUtil
.
getStackTrace
(
e
));
ApiError
apiError
=
new
ApiError
(
BAD_REQUEST
.
value
(),
e
.
getMessage
());
ApiError
apiError
=
new
ApiError
(
BAD_REQUEST
.
value
(),
e
.
getMessage
());
...
...
eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java
View file @
5ece3a3d
...
@@ -42,14 +42,10 @@ public class LogAspect {
...
@@ -42,14 +42,10 @@ public class LogAspect {
* @param joinPoint join point for advice
* @param joinPoint join point for advice
*/
*/
@Around
(
"logPointcut()"
)
@Around
(
"logPointcut()"
)
public
Object
logAround
(
ProceedingJoinPoint
joinPoint
){
public
Object
logAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
Object
result
=
null
;
Object
result
=
null
;
currentTime
=
System
.
currentTimeMillis
();
currentTime
=
System
.
currentTimeMillis
();
try
{
result
=
joinPoint
.
proceed
();
result
=
joinPoint
.
proceed
();
}
catch
(
Throwable
e
)
{
throw
new
BadRequestException
(
e
.
getMessage
());
}
Log
log
=
new
Log
(
"INFO"
,
System
.
currentTimeMillis
()
-
currentTime
);
Log
log
=
new
Log
(
"INFO"
,
System
.
currentTimeMillis
()
-
currentTime
);
logService
.
save
(
joinPoint
,
log
);
logService
.
save
(
joinPoint
,
log
);
return
result
;
return
result
;
...
...
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