private void throwOnCommonError(Response response) throws IOException {
  int status=response.code();
switch (status) {
case HttpStatus.SC_BAD_REQUEST:
    throw new MalformedRequestException();
case HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE:
  throw new UnsupportedMediaTypeException();
case HttpStatus.SC_NOT_FOUND:
throw new NotFoundException();
case HttpStatus.SC_UNAUTHORIZED:
throw new UnauthorizedException();
case HttpStatus.SC_FORBIDDEN:
throw new ForbiddenException();
case HttpStatus.SC_CONFLICT:
throw new ConflictException();
case HttpStatus.SC_UNPROCESSABLE_ENTITY:
throw new ValidationException();
}
if (status >= 400) {
throw new IOException("Unexpected status code on response: " + status);
}
}

private void throwOnCommonError ( Response response ) throws IOException { int status = response . code ( ) ; switch ( status ) { case HttpStatus . SC_BAD_REQUEST : throw new MalformedRequestException ( ) ; case HttpStatus . SC_UNSUPPORTED_MEDIA_TYPE : throw new UnsupportedMediaTypeException ( ) ; case HttpStatus . SC_NOT_FOUND : throw new NotFoundException ( ) ; case HttpStatus . SC_UNAUTHORIZED : throw new UnauthorizedException ( ) ; case HttpStatus . SC_FORBIDDEN : throw new ForbiddenException ( ) ; case HttpStatus . SC_CONFLICT : throw new ConflictException ( ) ; case HttpStatus . SC_UNPROCESSABLE_ENTITY : throw new ValidationException ( ) ; } if ( status >= 400 ) { throw new IOException ( "Unexpected status code on response: " + status ) ; } }
maps some of the common http errors to the corresponding exceptions .
