code: public HTTPResponse handleError(HTTPResponse response) throws HTTPException {
          if (response.statusCode < 200 || response.statusCode >= 300) {
              throw new HTTPException(response.statusCode, response.reason);
          }
          return response;
      }
docs: Handle http status error
  
  @param response   raw http response
  @return response  raw http response
  @throws HTTPException  http status exception