Skip to content

Commit

Permalink
[Imporve] Optimize log printing in GlobalExceptionHandler (#3707)
Browse files Browse the repository at this point in the history
[Imporve] Optimize log printing in GlobalExceptionHandler
  • Loading branch information
caicancai committed May 21, 2024
1 parent 3625222 commit a4a266e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ public class GlobalExceptionHandler {
@ExceptionHandler(value = Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public RestResponse handleException(Exception e) {
log.info("Internal server error:", e);
log.error("Internal server error:", e);
return RestResponse.fail(ResponseCode.CODE_FAIL, "internal server error: {}", e.getMessage());
}

@ExceptionHandler(value = HttpRequestMethodNotSupportedException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public RestResponse handleException(HttpRequestMethodNotSupportedException e) {
log.info("not supported request method,exception:{}", e.getMessage());
log.error("not supported request method,exception:{}", e);
return RestResponse.fail(
ResponseCode.CODE_FAIL, "not supported request method,exception:{}", e.getMessage());
}

@ExceptionHandler(value = AbstractApiException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public RestResponse handleException(AbstractApiException e) {
log.info("api exception:{}", e.getMessage());
log.error("api exception:{}", e);
return RestResponse.fail(e.getResponseCode(), e.getMessage());
}

Expand Down Expand Up @@ -113,6 +113,6 @@ public RestResponse handleConstraintViolationException(ConstraintViolationExcept
@ExceptionHandler(value = UnauthorizedException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
public void handleUnauthorizedException(Exception e) {
log.info("Permission denied,{}", e.getMessage());
log.error("Permission denied,{}", e);
}
}

0 comments on commit a4a266e

Please sign in to comment.