reduce error logging when fee and exchanges rate sources are unavailable

This commit is contained in:
Craig Raw 2021-04-08 08:34:31 +02:00
parent dcc63046bd
commit 57eb3a77e7
2 changed files with 16 additions and 4 deletions

View file

@ -56,7 +56,11 @@ public enum ExchangeSource {
Gson gson = new Gson();
return gson.fromJson(reader, CoinbaseRates.class);
} catch (Exception e) {
log.error("Error retrieving currency rates", e);
if(log.isDebugEnabled()) {
log.warn("Error retrieving currency rates", e);
} else {
log.warn("Error retrieving currency rates (" + e.getMessage() + ")");
}
return new CoinbaseRates();
}
}
@ -86,8 +90,12 @@ public enum ExchangeSource {
try(InputStream is = (proxy == null ? new URL(url).openStream() : new URL(url).openConnection(proxy).getInputStream()); Reader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
Gson gson = new Gson();
return gson.fromJson(reader, CoinGeckoRates.class);
} catch (Exception e) {
log.error("Error retrieving currency rates", e);
} catch(Exception e) {
if(log.isDebugEnabled()) {
log.warn("Error retrieving currency rates", e);
} else {
log.warn("Error retrieving currency rates (" + e.getMessage() + ")");
}
return new CoinGeckoRates();
}
}

View file

@ -87,7 +87,11 @@ public enum FeeRatesSource {
blockTargetFeeRates.put(Integer.MAX_VALUE, threeTierRates.minimumFee);
}
} catch (Exception e) {
log.warn("Error retrieving recommended fee rates from " + url, e);
if(log.isDebugEnabled()) {
log.warn("Error retrieving recommended fee rates from " + url, e);
} else {
log.warn("Error retrieving recommended fee rates from " + url + " (" + e.getMessage() + ")");
}
}
return blockTargetFeeRates;