Further replace magic number by HttpStatus

See gh-15130
This commit is contained in:
Stephane Nicoll 2018-12-03 15:48:13 +01:00
parent 9ee6303876
commit a85e27c7cd
1 changed files with 14 additions and 12 deletions

View File

@ -180,18 +180,20 @@ public final class WebMvcTags {
*/
public static Tag outcome(HttpServletResponse response) {
if (response != null) {
int status = response.getStatus();
if (status < 200) {
return OUTCOME_INFORMATIONAL;
}
if (status < 300) {
return OUTCOME_SUCCESS;
}
if (status < 400) {
return OUTCOME_REDIRECTION;
}
if (status < 500) {
return OUTCOME_CLIENT_ERROR;
HttpStatus status = extractStatus(response);
if (status != null) {
if (status.is1xxInformational()) {
return OUTCOME_INFORMATIONAL;
}
if (status.is2xxSuccessful()) {
return OUTCOME_SUCCESS;
}
if (status.is3xxRedirection()) {
return OUTCOME_REDIRECTION;
}
if (status.is4xxClientError()) {
return OUTCOME_CLIENT_ERROR;
}
}
return OUTCOME_SERVER_ERROR;
}