From 98f36360056811125b814c6de81d7c543bfbcd54 Mon Sep 17 00:00:00 2001 From: Agadar Date: Wed, 20 Nov 2019 16:35:27 +0100 Subject: [PATCH] Removed unnecessary comments and added info logging to TelegramQuery. --- .../agadar/nationstates/query/TelegramQuery.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/github/agadar/nationstates/query/TelegramQuery.java b/src/main/java/com/github/agadar/nationstates/query/TelegramQuery.java index c090b0f..c73bc89 100644 --- a/src/main/java/com/github/agadar/nationstates/query/TelegramQuery.java +++ b/src/main/java/com/github/agadar/nationstates/query/TelegramQuery.java @@ -121,24 +121,26 @@ public long estimatedDuration() { @Override public T execute(Class type) { - // Validate parameters and build base url. + validateQueryParameters(); String baseUrl = buildURL(); - // For each addressee, call makeRequest(...) if it isn't a dry run. for (int i = 0; i < nations.length && getRateLimiter().lock(); i++) { - // Build final url and wait for the rate limiter to go. + String nation = nations[i]; String url = baseUrl + nation.replace(' ', '_'); Exception exception = null; try { makeRequest(url, input -> null); + log.info("Queued a telegram to nation '{}'", nation); + } catch (Exception ex) { - log.error("An error occured while sending a telegram", ex); + String message = String.format("An error occured while queueing a telegram to nation '%s'", nation); + log.error(message, ex); exception = ex; + } finally { - // Always unlock the rate limiter to prevent deadlock. getRateLimiter().unlock(); } @@ -182,8 +184,7 @@ protected void validateQueryParameters() { @Override protected String buildURL() { String url = super.buildURL(); - url += String.format("&client=%s&tgid=%s&key=%s&to=", clientKey, telegramId, secretKey); // Append telegram - // fields. + url += String.format("&client=%s&tgid=%s&key=%s&to=", clientKey, telegramId, secretKey); return url; }