From ee30bff5ef0e40245004e1811a3a62c9caf4f30f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elisi=C3=A1rio=20Couto?= Date: Wed, 6 Mar 2024 18:32:14 +0000 Subject: [PATCH] fix: Print HTTP response body on errors. --- leggen/commands/sync.py | 4 ++-- leggen/utils/network.py | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/leggen/commands/sync.py b/leggen/commands/sync.py index 4415b06..2f8baff 100644 --- a/leggen/commands/sync.py +++ b/leggen/commands/sync.py @@ -119,5 +119,5 @@ def sync(ctx: click.Context): for account in accounts: try: save_transactions(ctx, account) - except Exception as e: - error(f"[{account}] Error: Sync failed, skipping account. Exception: {e}") + except Exception: + error(f"[{account}] Error: Sync failed, skipping account.") diff --git a/leggen/utils/network.py b/leggen/utils/network.py index 266abc6..3337a54 100644 --- a/leggen/utils/network.py +++ b/leggen/utils/network.py @@ -14,7 +14,7 @@ def get(ctx: click.Context, path: str, params: dict = {}): try: res.raise_for_status() except Exception as e: - error(f"Error: {e}") + error(f"Error: {e}\n{res.text}") ctx.abort() return res.json() @@ -29,7 +29,7 @@ def post(ctx: click.Context, path: str, data: dict = {}): try: res.raise_for_status() except Exception as e: - error(f"Error: {e}") + error(f"Error: {e}\n{res.text}") ctx.abort() return res.json() @@ -44,7 +44,6 @@ def put(ctx: click.Context, path: str, data: dict = {}): try: res.raise_for_status() except Exception as e: - error(f"Error: {e}") - error(res.text) + error(f"Error: {e}\n{res.text}") ctx.abort() return res.json()