X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=store.py;fp=store.py;h=3f3718f4f8c0bff4e253a0a090e5820bd8065726;hb=d8e233ac11edac1481f0315e25f79b0390c45e29;hp=2b5c18a1a1a65eb241af2677d322195a5202d18d;hpb=90d7423eec074a0ed0af680c223180f8d7e1d4e6;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git diff --git a/store.py b/store.py index 2b5c18a..3f3718f 100644 --- a/store.py +++ b/store.py @@ -176,15 +176,28 @@ class ReportStore: }) def log_http_request(self, method, url, body, headers, response): - self.add_log({ - "type": "http_request", - "method": method, - "url": url, - "body": body, - "headers": headers, - "status": response.status_code, - "response": response.text - }) + if isinstance(response, Exception): + self.add_log({ + "type": "http_request", + "method": method, + "url": url, + "body": body, + "headers": headers, + "status": -1, + "response": None, + "error": response.__class__.__name__, + "error_message": str(response), + }) + else: + self.add_log({ + "type": "http_request", + "method": method, + "url": url, + "body": body, + "headers": headers, + "status": response.status_code, + "response": response.text + }) def log_error(self, action, message=None, exception=None): self.print_log("[Error] {}".format(action))