(feat) add error handling for active instances

This commit is contained in:
cardosofede
2024-05-26 17:51:47 -05:00
parent 1a5ad0b6ec
commit 06ce36d304
3 changed files with 236 additions and 192 deletions

View File

@@ -109,7 +109,9 @@ class BackendAPIClient:
url = f"{self.base_url}/get-bot-status/{bot_name}"
response = requests.get(url)
if response.status_code == 200:
return response.json()["data"]
return response.json()
else:
return {"status": "error", "data": "Bot not found"}
def get_bot_history(self, bot_name: str):
"""Get the historical data of a bot."""
@@ -127,7 +129,7 @@ class BackendAPIClient:
if response.status_code == 200:
return response.json() # Successful request
else:
return response.json() # Handle errors or no data found
return {"status": "error", "data": "No active bots found"}
def get_all_controllers_config(self):
"""Get all controller configurations."""