From e8b8de7ca0bc8bcc141ac043054779f78a369a8d Mon Sep 17 00:00:00 2001 From: mischa Date: Fri, 8 Jul 2022 23:52:24 +0200 Subject: [PATCH] catch all 4xx error codes with POST --- push.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/push.py b/push.py index 3c470f9..13e2d20 100755 --- a/push.py +++ b/push.py @@ -136,8 +136,9 @@ def alkira_post(session, uri, body): url = f'{ALKIRA_BASE_URI}{uri}' try: response = session.post(url, data=json.dumps(body), headers=headers) - if response.status_code == 400: - logging.error(response.content) + match int(str(response.status_code)[0]): + case 4: + logging.error(response.content) response.raise_for_status() except Exception as e: logging.error(f'Error: {str(e)}')