List of usage examples for java.net HttpRetryException HttpRetryException
public HttpRetryException(String detail, int code)
From source file:ai.grakn.client.LoaderClient.java
/** * Fetch the status of a single task from the Tasks Controller * @param id ID of the task to be fetched * @return Json object containing status of the task *//*from w w w .j a v a 2 s .co m*/ private Json getStatus(String id) throws HttpRetryException { HttpURLConnection connection = null; try { URL url = new URL(format(GET, uri, id)); connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); // create post connection.setRequestMethod(REST.HttpConn.GET_METHOD); if (connection.getResponseCode() == 404) { throw new IllegalArgumentException("Not found in Grakn task storage: " + id); } // get response return Json.read(readResponse(connection.getInputStream())); } catch (IOException e) { throw new HttpRetryException(ErrorMessage.ERROR_COMMUNICATING_TO_HOST.getMessage(uri), 404); } finally { if (connection != null) { connection.disconnect(); } } }