Skip to content

Commit

Permalink
Merge pull request #845 from Agenta-AI/minor_improvement_error_handling
Browse files Browse the repository at this point in the history
improved error handling
  • Loading branch information
mmabrouk authored Oct 31, 2023
2 parents 374c997 + cba58ce commit b3c3ba5
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 b3c3ba5

Please sign in to comment.