Skip to content

Commit 5ece3a3

Browse files
committed
修复bug:重新catch再throw new Exception会导致部分堆栈信息丢失
1 parent 90c2bf9 commit 5ece3a3

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public class GlobalExceptionHandler {
2626
* @param e
2727
* @return
2828
*/
29-
@ExceptionHandler(Exception.class)
30-
public ResponseEntity handleException(Exception e){
29+
@ExceptionHandler(Throwable.class)
30+
public ResponseEntity handleException(Throwable e){
3131
// 打印堆栈信息
3232
log.error(ThrowableUtil.getStackTrace(e));
3333
ApiError apiError = new ApiError(BAD_REQUEST.value(),e.getMessage());

eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,10 @@ public void logPointcut() {
4242
* @param joinPoint join point for advice
4343
*/
4444
@Around("logPointcut()")
45-
public Object logAround(ProceedingJoinPoint joinPoint){
45+
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
4646
Object result = null;
4747
currentTime = System.currentTimeMillis();
48-
try {
49-
result = joinPoint.proceed();
50-
} catch (Throwable e) {
51-
throw new BadRequestException(e.getMessage());
52-
}
48+
result = joinPoint.proceed();
5349
Log log = new Log("INFO",System.currentTimeMillis() - currentTime);
5450
logService.save(joinPoint, log);
5551
return result;

0 commit comments

Comments
 (0)