提交 97ebc14c 编写于 作者: E Elune 提交者: Gitee

!3 修复bug:重新catch再throw new Exception会导致部分堆栈信息丢失

Merge pull request !3 from Edin/master
...@@ -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());
......
...@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册