1
0

exchange_rate: log full traceback in case of unexpected exception

related: #6748
This commit is contained in:
SomberNight
2020-11-20 01:45:11 +01:00
parent 57768244bb
commit 13563697f5

View File

@@ -11,6 +11,7 @@ from decimal import Decimal
from typing import Sequence, Optional
from aiorpcx.curio import timeout_after, TaskTimeout, TaskGroup
import aiohttp
from . import util
from .bitcoin import COIN
@@ -82,9 +83,12 @@ class ExchangeBase(Logger):
except asyncio.CancelledError:
# CancelledError must be passed-through for cancellation to work
raise
except BaseException as e:
except aiohttp.ClientError as e:
self.logger.info(f"failed fx quotes: {repr(e)}")
self.quotes = {}
except Exception as e:
self.logger.exception(f"failed fx quotes: {repr(e)}")
self.quotes = {}
self.on_quotes()
def read_historical_rates(self, ccy, cache_dir) -> Optional[dict]:
@@ -110,9 +114,12 @@ class ExchangeBase(Logger):
self.logger.info(f"requesting fx history for {ccy}")
h = await self.request_history(ccy)
self.logger.info(f"received fx history for {ccy}")
except BaseException as e:
except aiohttp.ClientError as e:
self.logger.info(f"failed fx history: {repr(e)}")
return
except Exception as e:
self.logger.exception(f"failed fx history: {repr(e)}")
return
filename = os.path.join(cache_dir, self.name() + '_' + ccy)
with open(filename, 'w', encoding='utf-8') as f:
f.write(json.dumps(h))