From 57eb3a77e7856792b0240aa3e8d1460ecc17c2ab Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 8 Apr 2021 08:34:31 +0200 Subject: [PATCH] reduce error logging when fee and exchanges rate sources are unavailable --- .../sparrowwallet/sparrow/net/ExchangeSource.java | 14 +++++++++++--- .../sparrowwallet/sparrow/net/FeeRatesSource.java | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java b/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java index e6d25180..8fb5e0b2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java @@ -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(); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java b/src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java index 487d8a82..2351f564 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java @@ -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;