mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 15:02:07 -03:30
Slightly better error handling for non 200 status codes from Gateway. (#7038)
* Slightly better error handling for non 200 status codes from Gateway. * Apply suggestion from @chrismeyersfsu Co-authored-by: Chris Meyers <chrismeyersfsu@users.noreply.github.com> --------- Co-authored-by: Chris Meyers <chrismeyersfsu@users.noreply.github.com>
This commit is contained in:
parent
d452098123
commit
a0b6083d4e
@ -464,17 +464,18 @@ class GatewayClient:
|
||||
# Return the specific setting value or None if not found
|
||||
return settings_data.get(setting_name)
|
||||
else:
|
||||
error_msg = f"Failed to get Gateway settings. Status: {response.status_code}"
|
||||
error_msg = f"Failed to get Gateway settings from '{endpoint}' for '{setting_name}'. Status: {response.status_code}"
|
||||
error_data = response.text
|
||||
try:
|
||||
error_data = response.json()
|
||||
error_msg += f", Error: {error_data}"
|
||||
except requests.exceptions.JSONDecodeError:
|
||||
error_msg += f", Response: {response.text}"
|
||||
|
||||
raise GatewayAPIError(error_msg, response.status_code, response.json() if response.content else None)
|
||||
raise GatewayAPIError(error_msg, response.status_code, error_data)
|
||||
|
||||
except requests.RequestException as e:
|
||||
raise GatewayAPIError(f"Failed to get Gateway setting: {str(e)}")
|
||||
raise GatewayAPIError(f"Failed to get Gateway settings from '{endpoint}' for '{setting_name}'. Unexpected Exception - Error: {str(e)}")
|
||||
|
||||
def get_base_url(self) -> str:
|
||||
"""Get the base URL of the Gateway instance.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user