private InstagramException handleInstagramError(Response response) throws InstagramException { if (response.getCode() == 400) { Gson gson = new Gson(); final InstagramErrorResponse error; try { System.out.println(response.getBody()); error = gson.fromJson(response.getBody(), InstagramErrorResponse.class); } catch (JsonSyntaxException e) { throw new InstagramException("Failed to decode error response " + response.getBody(), e); } error.throwException(); } throw new InstagramException( "Unknown error response code: " + response.getCode() + " " + response.getBody()); }
protected InstagramException handleInstagramError(Response response) throws InstagramException { Gson gson = new Gson(); final InstagramErrorResponse error; try { if (response.getCode() == 400) { error = InstagramErrorResponse.parse(gson, response.getBody()); error.setHeaders(response.getHeaders()); error.throwException(); } // sending too many requests too quickly; // limited to 5000 requests per hour per access_token or client_id overall. (according to // spec) else if (response.getCode() == 503) { error = InstagramErrorResponse.parse(gson, response.getBody()); error.setHeaders(response.getHeaders()); error.throwException(); } } catch (JsonSyntaxException e) { throw new InstagramException( "Failed to decode error response " + response.getBody(), e, response.getHeaders()); } throw new InstagramException( "Unknown error response code: " + response.getCode() + " " + response.getBody(), response.getHeaders()); }