From 3340b6d4dabc25747a44e1a7347a2a87fe2eaa82 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Tue, 28 Dec 2021 14:09:33 +0000 Subject: [PATCH] Additional error handling --- handler/agora.py | 7 ++++++- handler/revolut.py | 1 + handler/transactions.py | 10 ++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/handler/agora.py b/handler/agora.py index db673f9..f4118d7 100644 --- a/handler/agora.py +++ b/handler/agora.py @@ -49,6 +49,9 @@ class Agora(object): """ dash = self.agora.dashboard_seller() dash_tmp = [] + if "data" not in dash["response"].keys(): + self.log.error("Data not in dashboard response: {content}", content=dash) + return False if dash["response"]["data"]["contact_count"] > 0: for contact in dash["response"]["data"]["contact_list"]: contact_id = contact["data"]["contact_id"] @@ -69,7 +72,6 @@ class Agora(object): return False if dash["response"]["data"]["contact_count"] > 0: for contact in dash["response"]["data"]["contact_list"]: - print(f"CONTACT {contact}") contact_id = contact["data"]["contact_id"] current_trades.append(contact_id) buyer = contact["data"]["buyer"]["username"] @@ -101,6 +103,7 @@ class Agora(object): dash = self.agora.dashboard_seller() dash_tmp = [] if "data" not in dash["response"]: + self.log.error("Data not in dashboard response: {content}", content=dash) return False if dash["response"]["data"]["contact_count"] > 0: for contact in dash["response"]["data"]["contact_list"]: @@ -147,6 +150,8 @@ class Agora(object): :rtype: dict with lists """ dash = self.dashboard_id_only() + if dash is None: + return False messages_tmp = {} for contact_id in dash: messages = self.get_messages(contact_id, send_irc=send_irc) diff --git a/handler/revolut.py b/handler/revolut.py index 5410033..0e33643 100644 --- a/handler/revolut.py +++ b/handler/revolut.py @@ -184,6 +184,7 @@ class Revolut(object): if r.status_code == 200: return r.json() else: + self.log.error("Error getting accounts: {content}", content=r.content) return False def get_total_usd(self): diff --git a/handler/transactions.py b/handler/transactions.py index 8b29743..128a4be 100644 --- a/handler/transactions.py +++ b/handler/transactions.py @@ -52,11 +52,17 @@ class Transactions(object): txid = inside["id"] txtype = inside["type"] state = inside["state"] - reference = inside["reference"] + if "reference" in inside: + reference = inside["reference"] + else: + reference = "not_given" leg = inside["legs"][0] - account_type = leg["counterparty"]["account_type"] + if "counterparty" in leg: + account_type = leg["counterparty"]["account_type"] + else: + account_type = "not_given" amount = leg["amount"] currency = leg["currency"]