异常打印
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
package cn.ysk.cashier.config;
|
package cn.ysk.cashier.config;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.utils.FastJsonUtils;
|
import cn.ysk.cashier.utils.FastJsonUtils;
|
||||||
import cn.ysk.cashier.utils.SpringContextHolder;
|
import cn.ysk.cashier.utils.SpringContextHolder;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
@@ -40,7 +40,7 @@ public class AppApiMethodAspect {
|
|||||||
|
|
||||||
@Around("pkg()")
|
@Around("pkg()")
|
||||||
// @SuppressWarnings("unchecked")
|
// @SuppressWarnings("unchecked")
|
||||||
public Object around(ProceedingJoinPoint pjp) throws JsonProcessingException {
|
public Object around(ProceedingJoinPoint pjp) {
|
||||||
HttpServletRequest req = SpringContextHolder.getRequest();
|
HttpServletRequest req = SpringContextHolder.getRequest();
|
||||||
Signature sign = pjp.getSignature();
|
Signature sign = pjp.getSignature();
|
||||||
MethodSignature ms = (MethodSignature) sign;
|
MethodSignature ms = (MethodSignature) sign;
|
||||||
@@ -61,6 +61,13 @@ public class AppApiMethodAspect {
|
|||||||
FastJsonUtils.toJSONString(params),
|
FastJsonUtils.toJSONString(params),
|
||||||
FastJsonUtils.toJSONString(result)
|
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) {
|
} catch (Throwable e) {
|
||||||
if(StringUtils.isBlank(e.getMessage())){
|
if(StringUtils.isBlank(e.getMessage())){
|
||||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||||
@@ -76,6 +83,5 @@ public class AppApiMethodAspect {
|
|||||||
ResponseEntity<String> body = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
ResponseEntity<String> body = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user