提交 5ece3a3d 编写于 作者: Z zhuon

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

上级 90c2bf90
......@@ -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());
......
......@@ -42,14 +42,10 @@ public class LogAspect {
* @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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册