Code example for HttpResponseException

0
      HttpEntity entity = response.getEntity();
      return entity == null ? null : EntityUtils.toString(entity);
    } else if (status.getStatusCode() == 304) {
      return null; 
    } else { 
      throw new HttpResponseException(status.getStatusCode(), status.getReasonPhrase());
    } 
  } 
 
  protected <T> T parseJsonObject(JSONObject object, Class<T> klass) throws Exception {
    T instance = klass.newInstance();
 
    for (Field f : klass.getDeclaredFields()) {
      if (object.has(f.getName())) {
        Object o = object.get(f.getName());
        if (o.getClass().equals(JSONObject.class)) {
          f.set(instance, parseJsonObject((JSONObject) o, f.getType()));
        } else if (o.getClass().equals(JSONArray.class)) {
          f.set(instance, parseJsonArray((JSONArray) o, f.getType().getComponentType()));
        } else { 
          f.set(instance, o);