check for 4xx Http Code with native Java
I'm actually utilizing javax.ws.rs.core.Response.Status.Family
now. Thank you @Kon for the useful hint!
import javax.ws.rs.core.Response.Status.Family;
if (Family.familyOf(responseCode) == Family.CLIENT_ERROR) {
If using Spring you can simply do :
HttpStatus.valueOf(statusCode).is4xxClientError()
You can also look at is4xxClientError() implementation if you need anything extra