[#12235]Fix the incorrect logging format in the ResponseExceptionHandler of the naming module. (#12236)

This commit is contained in:
HMYDK 2024-06-24 09:41:25 +08:00 committed by GitHub
parent 3b2f787d61
commit 27da090b7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,10 +42,10 @@ public class ResponseExceptionHandler {
*/
@ExceptionHandler(NacosException.class)
public ResponseEntity<String> handleNacosException(NacosException e) {
Loggers.SRV_LOG.error("got exception. {}", e.getErrMsg(), ExceptionUtil.getAllExceptionMsg(e));
Loggers.SRV_LOG.error("got exception. {}", ExceptionUtil.getAllExceptionMsg(e));
return ResponseEntity.status(e.getErrCode()).body(e.getMessage());
}
/**
* Handle {@link com.alibaba.nacos.api.exception.runtime.NacosRuntimeException}.
*
@ -54,7 +54,7 @@ public class ResponseExceptionHandler {
*/
@ExceptionHandler(NacosRuntimeException.class)
public ResponseEntity<String> handleNacosRuntimeException(NacosRuntimeException e) {
Loggers.SRV_LOG.error("got exception. {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
Loggers.SRV_LOG.error("got exception. {}", ExceptionUtil.getAllExceptionMsg(e));
return ResponseEntity.status(e.getErrCode()).body(e.getMessage());
}
@ -66,7 +66,7 @@ public class ResponseExceptionHandler {
*/
@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<String> handleParameterError(IllegalArgumentException ex) {
Loggers.SRV_LOG.error("got exception. {}", ex.getMessage(), ExceptionUtil.getAllExceptionMsg(ex));
Loggers.SRV_LOG.error("got exception. {}", ExceptionUtil.getAllExceptionMsg(ex));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ex.getMessage());
}
@ -78,7 +78,7 @@ public class ResponseExceptionHandler {
*/
@ExceptionHandler(MissingServletRequestParameterException.class)
public ResponseEntity<String> handleMissingParams(MissingServletRequestParameterException ex) {
Loggers.SRV_LOG.error("got exception.", ExceptionUtil.getAllExceptionMsg(ex));
Loggers.SRV_LOG.error("got exception. {}", ExceptionUtil.getAllExceptionMsg(ex));
String name = ex.getParameterName();
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Parameter '" + name + "' is missing");
}
@ -91,7 +91,7 @@ public class ResponseExceptionHandler {
*/
@ExceptionHandler(Exception.class)
public ResponseEntity<String> handleException(Exception e) {
Loggers.SRV_LOG.error("got exception.", ExceptionUtil.getAllExceptionMsg(e));
Loggers.SRV_LOG.error("got exception. {}", ExceptionUtil.getAllExceptionMsg(e));
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(ExceptionUtil.getAllExceptionMsg(e));
}
}