Skip to content

Commit 5bf83bf

Browse files
committed
🔊 More details in patch message
1 parent 389054f commit 5bf83bf

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

kf_utils/dataservice/patch.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from pprint import pformat
12
from concurrent.futures import ThreadPoolExecutor, as_completed
23

34
# from d3b_utils.requests_retry import Session
@@ -16,10 +17,15 @@ def send_patches(host, patches):
1617
host = host.strip("/")
1718

1819
def do_patch(url, patch):
19-
msg = f"Patched {url} with {patch}"
2020
resp = Session().patch(url, json=patch)
2121
if not resp.ok:
22-
raise Exception(f"{resp.status_code} -- {msg} -- {resp.json()}")
22+
msg = f"Patched {url} with {patch}"
23+
raise Exception(
24+
f"{resp.status_code} -- {msg} -- Response:\n{resp.text}"
25+
)
26+
else:
27+
msg = f"Patched {url} with {patch}. Response:\n{pformat(resp.json())}"
28+
2329
return msg
2430

2531
with ThreadPoolExecutor() as tpex:

0 commit comments

Comments
 (0)