异常响应
订单管理 查询支付统计
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package cn.ysk.cashier.config;
|
||||
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.utils.FastJsonUtils;
|
||||
import cn.ysk.cashier.utils.SpringContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -11,8 +10,6 @@ import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -26,8 +23,6 @@ import java.util.Map;
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AppApiMethodAspect {
|
||||
|
||||
// @Pointcut("execution(public * cn.ysk.cashier.controller.*.*(..))")
|
||||
@Pointcut("execution(public * (" +
|
||||
"cn.ysk.cashier.controller.* " +
|
||||
"|| cn.ysk.cashier.controller.*.* " +
|
||||
@@ -62,26 +57,31 @@ public class AppApiMethodAspect {
|
||||
FastJsonUtils.toJSONString(result)
|
||||
);
|
||||
return result;
|
||||
} catch (BadRequestException e) {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
|
||||
} catch (Throwable e) {
|
||||
if(StringUtils.isBlank(e.getMessage())){
|
||||
} catch (RuntimeException e) {
|
||||
if (StringUtils.isBlank(e.getMessage())) {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e);
|
||||
}else{
|
||||
} else {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e.getMessage());
|
||||
}
|
||||
ResponseEntity<String> body = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||
return body;
|
||||
throw e;
|
||||
} catch (Error e) {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e);
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user