Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Dec 18, 2023
1 parent c8972da commit ae4ba41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 6 additions & 5 deletions rxlib/src/main/java/org/rx/spring/Interceptors.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ protected Tuple<HttpServletRequest, HttpServletResponse> httpEnv() {
return null;
}

@SneakyThrows
@ExceptionHandler({Exception.class})
@ExceptionHandler({Throwable.class})
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public Object onException(Exception e, HttpServletRequest request) {
TraceHandler.INSTANCE.log(request.getRequestURL().toString(), e);
public Object onException(Throwable e, HttpServletRequest request) {
if (!Boolean.TRUE.equals(request.getAttribute("_skipGlobalLog"))) {
TraceHandler.INSTANCE.log(request.getRequestURL().toString(), e);
}
String msg = null;
if (e instanceof MethodArgumentNotValidException) {
FieldError fieldError = ((MethodArgumentNotValidException) e).getBindingResult().getFieldError();
Expand All @@ -140,7 +141,7 @@ public Object onException(Exception e, HttpServletRequest request) {
}

if (SpringContext.controllerExceptionHandler != null) {
return SpringContext.controllerExceptionHandler.invoke(e, msg);
return SpringContext.controllerExceptionHandler.apply(e, msg);
}
return new ResponseEntity<>(msg, HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand Down
5 changes: 2 additions & 3 deletions rxlib/src/main/java/org/rx/util/Servlets.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static String requestIp() {
String[] ips = Strings.split(ip, ",");
if (ips.length > 1) {
ip = ips[0];
//.trim();
//.trim();
}
return ip;
}
Expand All @@ -80,9 +80,8 @@ public static String requestIp(boolean throwOnEmpty) {
} catch (Throwable e) {
if (throwOnEmpty) {
throw InvalidException.sneaky(e);
} else {
TraceHandler.INSTANCE.log(e);
}
TraceHandler.INSTANCE.log(e);
return "0.0.0.0";
}
}
Expand Down

0 comments on commit ae4ba41

Please sign in to comment.