Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

fix: Catch any error for readiness

Clémence Lesné6b4f22c12668
diff --git a/persistence/ai_search.py b/persistence/ai_search.py
index e76e0fa..ca95f94 100644
--- a/persistence/ai_search.py
+++ b/persistence/ai_search.py
@@ -53,10 +53,14 @@ class AiSearchSearch(ISearch):
async with await self._use_client() as client:
await client.get_document_count()
return ReadinessEnum.OK
- except HttpResponseError as e:
- logger.error(f"Error requesting AI Search: {e}")
- except ServiceRequestError as e:
- logger.error(f"Error connecting to AI Search: {e}")
+ except HttpResponseError:
+ logger.error("Error requesting AI Search", exc_info=True)
+ except ServiceRequestError:
+ logger.error("Error connecting to AI Search", exc_info=True)
+ except Exception:
+ logger.error(
+ "Unknown error while checking AI Search readiness", exc_info=True
+ )
return ReadinessEnum.FAIL
@retry(
diff --git a/persistence/cosmos_db.py b/persistence/cosmos_db.py
index 0045a4d..9dbdac7 100644
--- a/persistence/cosmos_db.py
+++ b/persistence/cosmos_db.py
@@ -62,8 +62,12 @@ class CosmosDbStore(IStore):
return ReadinessEnum.OK
except AssertionError:
logger.error("Readiness test failed", exc_info=True)
- except CosmosHttpResponseError as e:
- logger.error(f"Error requesting CosmosDB: {e}")
+ except CosmosHttpResponseError:
+ logger.error("Error requesting CosmosDB", exc_info=True)
+ except Exception:
+ logger.error(
+ "Unknown error while checking Cosmos DB readiness", exc_info=True
+ )
return ReadinessEnum.FAIL
async def _item_exists(self, test_id: str, partition_key: str) -> bool:
diff --git a/persistence/redis.py b/persistence/redis.py
index 1171219..74cbe96 100644
--- a/persistence/redis.py
+++ b/persistence/redis.py
@@ -63,10 +63,12 @@ class RedisCache(ICache):
# Test the item does not exist
assert await self._client.get(test_name) is None
return ReadinessEnum.OK
- except AssertionError as e:
- logger.error(f"Readiness test failed: {e}")
+ except AssertionError:
+ logger.error("Readiness test failed", exc_info=True)
except RedisError as e:
- logger.error(f"Error requesting Redis: {e}")
+ logger.error("Error requesting Redis", exc_info=True)
+ except Exception:
+ logger.error("Unknown error while checking Redis readiness", exc_info=True)
return ReadinessEnum.FAIL
async def aget(self, key: str) -> Optional[bytes]:
diff --git a/persistence/sqlite.py b/persistence/sqlite.py
index d115309..37e60ef 100644
--- a/persistence/sqlite.py
+++ b/persistence/sqlite.py
@@ -49,8 +49,8 @@ class SqliteStore(IStore):
async with self._use_db() as db:
await db.execute("SELECT 1")
return ReadinessEnum.OK
- except Exception as e:
- logger.error(f"Error requesting SQLite: {e}")
+ except Exception:
+ logger.error("Unknown error while checking SQLite readiness", exc_info=True)
return ReadinessEnum.FAIL
async def call_aget(self, call_id: UUID) -> Optional[CallStateModel]:
diff --git a/persistence/twilio.py b/persistence/twilio.py
index 1dc1be1..9fac94a 100644
--- a/persistence/twilio.py
+++ b/persistence/twilio.py
@@ -32,6 +32,8 @@ class TwilioSms(ISms):
return ReadinessEnum.OK
except AssertionError:
logger.error("Readiness test failed", exc_info=True)
+ except Exception:
+ logger.error("Unknown error while checking Twilio readiness", exc_info=True)
return ReadinessEnum.FAIL
async def asend(self, content: str, phone_number: PhoneNumber) -> bool: