File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,11 +13,13 @@ def get_database_connector(config: Config) -> DatabaseConnectorBase:
1313 This allow them to be lazy-imported. This also allow us to keep the main package
1414 lightweight because we don't have to include dependencies for EVERY database.
1515
16+ > Raises a `ValueError` in case the database connector is not supported.
1617 """
1718 cls : Optional [Type [DatabaseConnectorBase ]] = None
1819
1920 if not config .db_type .endswith ("Connector" ):
2021 config .db_type = f"{ config .db_type } Connector"
22+ logger .debug (f"Correcting the name of the db connector to { config .db_type } " )
2123
2224 match config .db_type :
2325 case "ChromaDB0Connector" :
@@ -28,3 +30,6 @@ def get_database_connector(config: Config) -> DatabaseConnectorBase:
2830 raise ValueError (f"Unrecognised database type: { config .db_type } " )
2931
3032 return cls .create (config )
33+
34+
35+ __all__ = ["get_database_connector" ]
Original file line number Diff line number Diff line change 1919logger = logging .getLogger (name = __name__ )
2020
2121
22+ """
23+ For developers:
24+
25+ To implement a custom database connector, you should inherit the following
26+ `DatabaseConnectorBase` class and implement ALL abstract methods.
27+
28+ You should also try to wrap the exceptions with the ones in
29+ `src/vectorcode/database/errors.py` where appropriate, because this helps the
30+ CLI/LSP/MCP interfaces to handle some common edge cases. To do this, you should do the following in a try-except block:
31+ ```python
32+ from vectorcode.database.errors import CollectionNotFoundError
33+
34+ try:
35+ some_action_here()
36+ except SomeCustomException as e:
37+ raise CollectionNotFoundError("The collection was not found.") from e
38+ ```
39+ This will preserve the correct call stack in the error message and makes debugging
40+ easier.
41+ """
42+
43+
2244class DatabaseConnectorBase (ABC ): # pragma: nocover
2345 @classmethod
2446 def create (cls , configs : Config ):
You can’t perform that action at this time.
0 commit comments