Skip to content

Commit

Permalink
improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mmabrouk committed Oct 31, 2023
1 parent b48ae3c commit cba58ce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion agenta-cli/agenta/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,21 @@ def list_variants(app_id: str, host: str, api_key: str = None) -> List[AppVarian
headers={"Authorization": api_key} if api_key is not None else None,
timeout=600,
)

# Check for successful request
if response.status_code == 403:
raise APIRequestError(
f"No app by id {app_id} exists or you do not have access to it."
)
elif response.status_code == 404:
raise APIRequestError(
f"No app by id {app_id} exists or you do not have access to it."
)
elif response.status_code != 200:
error_message = response.json()
raise APIRequestError(
f"Request to apps endpoint failed with status code {response.status_code} and error message: {error_message}."
)

app_variants = response.json()
return [AppVariant(**variant) for variant in app_variants]

Expand Down

0 comments on commit cba58ce

Please sign in to comment.