Skip to content

Commit

Permalink
修复bug:重新catch再throw new Exception会导致部分堆栈信息丢失
Browse files Browse the repository at this point in the history
  • Loading branch information
Edinjohn committed May 24, 2019
1 parent 90c2bf9 commit 5ece3a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class GlobalExceptionHandler {
* @param e
* @return
*/
@ExceptionHandler(Exception.class)
public ResponseEntity handleException(Exception e){
@ExceptionHandler(Throwable.class)
public ResponseEntity handleException(Throwable e){
// 打印堆栈信息
log.error(ThrowableUtil.getStackTrace(e));
ApiError apiError = new ApiError(BAD_REQUEST.value(),e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,10 @@ public void logPointcut() {
* @param joinPoint join point for advice
*/
@Around("logPointcut()")
public Object logAround(ProceedingJoinPoint joinPoint){
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
Object result = null;
currentTime = System.currentTimeMillis();
try {
result = joinPoint.proceed();
} catch (Throwable e) {
throw new BadRequestException(e.getMessage());
}
result = joinPoint.proceed();
Log log = new Log("INFO",System.currentTimeMillis() - currentTime);
logService.save(joinPoint, log);
return result;
Expand Down

0 comments on commit 5ece3a3

Please sign in to comment.