原因
在一个AOP切面里面,try{}catch{},异常被拦截消费了 我的解决方案是在catch里判断如果是我门自己自定义的异常 再throw出去,这样统一异常处理的地方就可以实现了。
try {
log.info("request methodName: " + methodName);
log.info("request URL: " + request.getRequestURL());
log.info("request params: " + JSONObject.toJSONString(arrays));
result = proceedingJoinPoint.proceed();
log.info("request URL: " + request.getRequestURL());
log.info("response result :" + JSONObject.toJSONString(result));
} catch (Throwable e) {
log.error(request.getServletPath() + " occurs exception :" + e, e);
//判断异常是否是自己需要统一处理的异常抛出去或者不是本次需要catch的异常直接抛出去
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
e.printStackTrace();
}