catch all 4xx error codes with POST

This commit is contained in:
mischa 2022-07-08 23:52:24 +02:00
parent 5f0eb2bc4c
commit e8b8de7ca0
1 changed files with 3 additions and 2 deletions

View File

@ -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)}')