public static JsonObject getJsonForURL(String url, List<ResponseErrors> possibleErrors) {
        HttpURLConnection connection = null;
        StringBuilder builder = null;
        JsonObject json = null;
        
        try {
            URL inputURL = new URL(url);
            connection = (HttpURLConnection) inputURL.openConnection();
            builder = new StringBuilder();
            InputStream inputStream = null;
            
            String inputLine;

            int responseCode = connection.getResponseCode();

            for(ResponseErrors recognizedError : possibleErrors) {
            	if(recognizedError.getCode() == responseCode) {
            		throw new ResponseErrors(recognizedError.getMessage());
            	}
            }
            try {
                inputStream = connection.getInputStream();
            } catch (FileNotFoundException e) {
                throw new ResponseErrors("Error code 404");
            }
            
            if (inputStream == null) {
                throw new ResponseErrors("Empty Response");
            }

            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            while ((inputLine = reader.readLine()) != null) {
                    builder.append(inputLine);
            }
            json = new JsonObject(builder.toString());
            
        } catch (IOException e) {
                e.printStackTrace();
        } catch (ResponseErrors re) {
                re.printStackTrace();
        }
        return json;
	}