@@ -156,11 +156,18 @@ class MilvusUploader(Uploader):
156156
157157 @DestinationConnectionError .wrap
158158 def precheck (self ):
159- with self .get_client () as client :
160- if not client .has_collection (self .upload_config .collection_name ):
161- raise DestinationConnectionError (
162- f"Collection '{ self .upload_config .collection_name } ' does not exist"
163- )
159+ from pymilvus import MilvusException
160+
161+ try :
162+ with self .get_client () as client :
163+ if not client .has_collection (self .upload_config .collection_name ):
164+ raise DestinationConnectionError (
165+ f"Collection '{ self .upload_config .collection_name } ' does not exist"
166+ )
167+ except MilvusException as milvus_exception :
168+ raise DestinationConnectionError (
169+ f"failed to precheck Milvus: { str (milvus_exception .message )} "
170+ ) from milvus_exception
164171
165172 @contextmanager
166173 def get_client (self ) -> Generator ["MilvusClient" , None , None ]:
@@ -197,7 +204,9 @@ def insert_results(self, data: Union[dict, list[dict]]):
197204 try :
198205 res = client .insert (collection_name = self .upload_config .collection_name , data = data )
199206 except MilvusException as milvus_exception :
200- raise WriteError ("failed to upload records to milvus" ) from milvus_exception
207+ raise WriteError (
208+ f"failed to upload records to Milvus: { str (milvus_exception .message )} "
209+ ) from milvus_exception
201210 if "err_count" in res and isinstance (res ["err_count" ], int ) and res ["err_count" ] > 0 :
202211 err_count = res ["err_count" ]
203212 raise WriteError (f"failed to upload { err_count } docs" )
0 commit comments