|
@@ -88,10 +88,33 @@ public class GlobalExceptionInterceptor extends AbstractErrorController implemen
|
|
|
try {
|
|
|
chain.doFilter(request, response);
|
|
|
} catch (Exception e) {
|
|
|
- LoggingContextHolder.error(log, request, false, e);
|
|
|
+ if (this.isClientAbortException(e)) {
|
|
|
+ LoggingContextHolder.warn(log, request, false, e, this.isWarnTracing());
|
|
|
+ } else {
|
|
|
+ LoggingContextHolder.error(log, request, false, e);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 是否开启告警日志异常堆栈打印
|
|
|
+ *
|
|
|
+ * @return true/false
|
|
|
+ */
|
|
|
+ private boolean isWarnTracing() {
|
|
|
+ return ApplicationContextHolder.getProperty("global.warn.tracing", boolean.class, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断是否是客户端中断异常
|
|
|
+ *
|
|
|
+ * @param e 异常对象
|
|
|
+ * @return true/false
|
|
|
+ */
|
|
|
+ private boolean isClientAbortException(Exception e) {
|
|
|
+ return e != null && CLIENT_ABORT_EXCEPTION.equals(e.getClass().getName());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 参数绑定结果格式化
|
|
|
*
|
|
@@ -269,12 +292,11 @@ public class GlobalExceptionInterceptor extends AbstractErrorController implemen
|
|
|
Result<?> result = this.error2result(ErrorUtils.real(e));
|
|
|
HttpStatus status = result.status();
|
|
|
response.setStatus(status.value());
|
|
|
- boolean aborted = CLIENT_ABORT_EXCEPTION.equals(e.getClass().getName());
|
|
|
+ boolean aborted = this.isClientAbortException(e);
|
|
|
if (status.is5xxServerError() && !aborted) {
|
|
|
LoggingContextHolder.error(log, request, e);
|
|
|
} else {
|
|
|
- boolean tracing = ApplicationContextHolder.getProperty("global.warn.tracing", boolean.class, false);
|
|
|
- LoggingContextHolder.warn(log, request, e, tracing);
|
|
|
+ LoggingContextHolder.warn(log, request, e, this.isWarnTracing());
|
|
|
}
|
|
|
return aborted ? null : result;
|
|
|
}
|