From a56f9c79ab793e5ab6a297053ae3728d86cc1d2f Mon Sep 17 00:00:00 2001 From: Beq Date: Mon, 16 Sep 2024 21:35:26 +0100 Subject: [PATCH] remove the exception handler --- fsutils/download_list.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fsutils/download_list.py b/fsutils/download_list.py index b5b0923d0d..95f65f9ef1 100644 --- a/fsutils/download_list.py +++ b/fsutils/download_list.py @@ -380,26 +380,30 @@ def update_fs_version_mgr(build_info, config): try: response = requests.post(url, json=payload, headers=headers) - response.raise_for_status() - # Parse the response data - response_data = response.json() - result = response_data.get('result') - message = response_data.get('message') - - if result == 'success': - print(f"Version manager updated successfully for {os_name} {build_variant}") + # Manually check for status code instead of raising an exception + if response.status_code == 200: + response_data = response.json() + result = response_data.get('result') + message = response_data.get('message') + + if result == 'success': + print(f"Version manager updated successfully for {os_name} {build_variant}") + else: + print(f"Error updating version manager: {message}") else: - print(f"Error updating version manager: {message}") + print(f"Unexpected status code received: {response.status_code}") + print(f"Response body: {response.text}") except requests.exceptions.RequestException as e: print(f"API request failed: {e}") - # Check if response is available and check for status code 403 + # Additional error handling if response and response.status_code == 403: print("Status Code:", response.status_code) print("Response Headers:", response.headers) print("Response Body:", response.text) + except ValueError: print("API response is not valid JSON")