@@ -45,10 +45,11 @@ class CassandraDatabase(BaseDatabase):
4545 _table : ClusteredMetadataVectorCassandraTable
4646
4747 def __new__ (cls ) -> Self : # noqa: D102
48- raise ValueError (
48+ msg = (
4949 "This class cannot be instantiated directly. "
5050 "Please use the `from_astra()` or `from_session()` class methods."
5151 )
52+ raise ValueError (msg )
5253
5354 @classmethod
5455 def from_astra (
@@ -173,10 +174,11 @@ def add_chunks(self, chunks: list[Chunk]) -> list[tuple[str, int]]:
173174 success_chunks .append ((doc_id , chunk_id ))
174175
175176 if len (failed_chunks ) > 0 :
176- raise CassandraDatabaseError (
177+ msg = (
177178 f"add failed for these chunks: { failed_chunks } . "
178179 f"See error logs for more info."
179180 )
181+ raise CassandraDatabaseError (msg )
180182
181183 return success_chunks
182184
@@ -273,10 +275,11 @@ async def aadd_chunks(
273275 failed_chunks .append ((doc_id , chunk_id ))
274276
275277 if len (failed_chunks ) > 0 :
276- raise CassandraDatabaseError (
278+ msg = (
277279 f"add failed for these chunks: { failed_chunks } . "
278280 f"See error logs for more info."
279281 )
282+ raise CassandraDatabaseError (msg )
280283
281284 return outputs
282285
@@ -292,8 +295,9 @@ def delete_chunks(self, doc_ids: list[str]) -> bool:
292295 failed_docs .append (doc_id )
293296
294297 if len (failed_docs ) > 0 :
298+ msg = "delete failed for these docs: %s. See error logs for more info."
295299 raise CassandraDatabaseError (
296- "delete failed for these docs: %s. See error logs for more info." ,
300+ msg ,
297301 failed_docs ,
298302 )
299303
@@ -340,10 +344,11 @@ async def adelete_chunks(
340344 failed_docs .append (doc_id )
341345
342346 if len (failed_docs ) > 0 :
343- raise CassandraDatabaseError (
347+ msg = (
344348 f"delete failed for these docs: { failed_docs } . "
345349 f"See error logs for more info."
346350 )
351+ raise CassandraDatabaseError (msg )
347352
348353 return success
349354
@@ -379,9 +384,8 @@ async def get_chunk_data(
379384 row = await self ._table .aget (partition_id = doc_id , row_id = row_id )
380385
381386 if row is None :
382- raise CassandraDatabaseError (
383- f"no chunk found for doc_id: { doc_id } chunk_id: { chunk_id } "
384- )
387+ msg = f"no chunk found for doc_id: { doc_id } chunk_id: { chunk_id } "
388+ raise CassandraDatabaseError (msg )
385389
386390 if include_embedding is True :
387391 embedded_chunk = await self .get_chunk_embedding (
0 commit comments