Skip to content

Commit

Permalink
AbstractQuery no longer error logs in case of self-thrown NationState…
Browse files Browse the repository at this point in the history
…sAPIException; TelegramQuery no longer error logs in case of NationStatesResourceNotFoundException.
  • Loading branch information
Agadar committed Aug 16, 2020
1 parent a12548a commit caaa315
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ protected <T> T makeRequest(String urlStr, CheckedFunction<InputStream, T> resul
throw new NationStatesAPIException(response);

} catch (Exception | OutOfMemoryError ex) {
log.error("An error occured while handling a request to the API", ex);
if (ex instanceof NationStatesAPIException) {
throw (NationStatesAPIException) ex;
}
log.error("An error occured while handling a request to the API", ex);
throw new NationStatesAPIException(ex);

} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.github.agadar.nationstates.event.TelegramSentEvent;
import com.github.agadar.nationstates.event.TelegramSentListener;
import com.github.agadar.nationstates.exception.NationStatesResourceNotFoundException;
import com.github.agadar.nationstates.ratelimiter.RateLimiter;

import lombok.NonNull;
Expand Down Expand Up @@ -133,9 +134,12 @@ public <T> T execute(Class<T> type) {
makeRequest(url, input -> null);
log.info("Queued a telegram to nation '{}'", nation);

} catch (NationStatesResourceNotFoundException ex) {
log.info("Nation '{}' was not found or doesn't exist", nation);
exception = ex;

} catch (Exception ex) {
String message = String.format("An error occured while queueing a telegram to nation '%s'", nation);
log.error(message, ex);
log.error(String.format("An error occured while queueing a telegram to nation '%s'", nation), ex);
exception = ex;

} finally {
Expand Down

0 comments on commit caaa315

Please sign in to comment.