Skip to content

Commit

Permalink
perf($Starter): refine error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnny Miller (锺俊) committed Dec 23, 2020
1 parent ab6249d commit 753946c
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public class ExceptionControllerAdvice {
*/
@ResponseBody
@ExceptionHandler(value = Exception.class)
public ResponseBodyBean<Object> handleException(HttpServletRequest request,
HttpServletResponse response,
@SuppressWarnings("AlibabaMethodTooLong")
public ResponseBodyBean<?> handleException(HttpServletRequest request, HttpServletResponse response,
Exception exception) {
log.error("Exception occurred when [{}] requested access. URL: {}", RequestUtil.getRequestIpAndPort(request),
request.getServletPath());
log.error("Exception occurred when [{}] requested access. Request URL: [{}] {}",
RequestUtil.getRequestIpAndPort(request), request.getMethod(), request.getRequestURL());

// FIXME: THIS IS NOT A PROBLEM
// ATTENTION: Use only ResponseBodyBean.ofStatus() in handleException() method and DON'T throw any exception
Expand Down Expand Up @@ -127,7 +127,8 @@ public ResponseBodyBean<Object> handleException(HttpServletRequest request,
}
log.error("Internal system exception occurred! Exception message: {} ", exception.getMessage(), exception);
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
return ResponseBodyBean.ofStatus(HttpStatus.INTERNAL_SERVER_ERROR.value(), exception.getMessage(), null);
return ResponseBodyBean.ofStatus(HttpStatus.INTERNAL_SERVER_ERROR,
"Exception message: " + exception.getMessage());
}

/**
Expand Down

0 comments on commit 753946c

Please sign in to comment.