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

pull/92/head
zhuon 2019-05-24 10:49:45 +08:00
parent 90c2bf906b
commit 5ece3a3d68
2 changed files with 4 additions and 8 deletions

View File

@ -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());

View File

@ -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());
}
Log log = new Log("INFO",System.currentTimeMillis() - currentTime);
logService.save(joinPoint, log);
return result;