Write the body of a failed transferwise request to stderr
authorMagnus Hagander <magnus@hagander.net>
Fri, 28 Feb 2025 13:21:00 +0000 (14:21 +0100)
committerMagnus Hagander <magnus@hagander.net>
Fri, 28 Feb 2025 13:21:55 +0000 (14:21 +0100)
postgresqleu/transferwise/api.py

index fa81ee2213570bb3e9639e78d650a98b175251c9..6bfdbb5bb67e12e67890c525a66a845d86fd073f 100644 (file)
@@ -6,6 +6,7 @@ from datetime import datetime, timedelta
 from decimal import Decimal
 import json
 import re
+import sys
 import uuid
 from base64 import b64encode
 
@@ -56,6 +57,8 @@ class TransferwiseApi(object):
                 },
             )
         if r.status_code != 200:
+            # Print the content of the error as well, so this can be picked up in a log
+            sys.stderr.write("API returned status {}. Body:\n{}".format(r.status_code, r.text[:2000]))
             r.raise_for_status()
         return r