fix 11892 keep ErrorResponse result code the same with errorcode (#11893)

This commit is contained in:
shalk(xiao kun) 2024-04-01 12:02:46 +08:00 committed by GitHub
parent 3a1f0c297e
commit 6461aeb719
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -57,6 +57,7 @@ public class ErrorResponse extends Response {
}
ErrorResponse response = new ErrorResponse();
response.setErrorInfo(errorCode, exception.getMessage());
response.setResultCode(errorCode);
return response;
}

View File

@ -31,6 +31,7 @@ public class ErrorResponseTest {
Response response = ErrorResponse.build(errorCode, msg);
Assert.assertEquals(errorCode, response.getErrorCode());
Assert.assertEquals(errorCode, response.getResultCode());
Assert.assertEquals(msg, response.getMessage());
}
@ -42,6 +43,7 @@ public class ErrorResponseTest {
Response response = ErrorResponse.build(runtimeException);
Assert.assertEquals(ResponseCode.FAIL.getCode(), response.getErrorCode());
Assert.assertEquals(ResponseCode.FAIL.getCode(), response.getResultCode());
Assert.assertEquals(errMsg, response.getMessage());
}
@ -54,6 +56,7 @@ public class ErrorResponseTest {
Response response = ErrorResponse.build(nacosException);
Assert.assertEquals(errCode, response.getErrorCode());
Assert.assertEquals(errCode, response.getResultCode());
Assert.assertEquals(errMsg, response.getMessage());
}
@ -66,7 +69,8 @@ public class ErrorResponseTest {
Response response = ErrorResponse.build(nacosRuntimeException);
Assert.assertEquals(errCode, response.getErrorCode());
Assert.assertEquals(errCode, response.getResultCode());
Assert.assertEquals("errCode: " + errCode + ", errMsg: " + errMsg + " ", response.getMessage());
}
}