code: public static InstagramErrorResponse parse(Gson gson, String json) {
          JsonElement jsonElement = gson.fromJson(json, JsonElement.class);
          JsonElement metaMember = null;
          if (jsonElement != null) {
              metaMember = jsonElement.getAsJsonObject().get("meta");
          }
          final Meta meta;
          if (metaMember != null) {
              meta = gson.fromJson(metaMember, Meta.class);
          } else {
              meta = gson.fromJson(jsonElement, Meta.class);
          }
  
          // Validate meta
          if (meta.getCode() != 0 && meta.getErrorType() != null) {
              return new InstagramErrorResponse(meta);
          } else {
              return new InstagramErrorResponse(null);
          }
      }
docs: Parse the specified json holding a response object. Instagram has two ways of
  specifying an error: either a meta attribute is set or the body of the
  response is a meta object itself.
  
  @param gson the gson instance to use
  @param json the json response content
  @return the InstagramErrorResponse object