Skip to content

Commit 5cce85b

Browse files
authored
[ENH] Add a better error message for HTTPClient connection errors (chroma-core#1349)
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - Add a better error message for HTTPClient connection errors during tenant/db validation on startup - New functionality - N/A
1 parent a41fab8 commit 5cce85b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

chromadb/api/client.py

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from uuid import UUID
33

44
from overrides import override
5+
import requests
56
from chromadb.api import AdminAPI, ClientAPI, ServerAPI
67
from chromadb.api.types import (
78
CollectionMetadata,
@@ -402,13 +403,21 @@ def set_database(self, database: str) -> None:
402403
def _validate_tenant_database(self, tenant: str, database: str) -> None:
403404
try:
404405
self._admin_client.get_tenant(name=tenant)
406+
except requests.exceptions.ConnectionError:
407+
raise ValueError(
408+
"Could not connect to a Chroma server. Are you sure it is running?"
409+
)
405410
except Exception:
406411
raise ValueError(
407412
f"Could not connect to tenant {tenant}. Are you sure it exists?"
408413
)
409414

410415
try:
411416
self._admin_client.get_database(name=database, tenant=tenant)
417+
except requests.exceptions.ConnectionError:
418+
raise ValueError(
419+
"Could not connect to a Chroma server. Are you sure it is running?"
420+
)
412421
except Exception:
413422
raise ValueError(
414423
f"Could not connect to database {database} for tenant {tenant}. Are you sure it exists?"

0 commit comments

Comments
 (0)