Skip to content

Commit c82f00f

Browse files
feat: pgvector - make error messages more informative (#1684)
* Include the actual SQL exception when reporting the error. * small improvements --------- Co-authored-by: Stefano Fiorucci <[email protected]>
1 parent 671bcc8 commit c82f00f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ GitHub. The GitHub Actions workflow will take care of the rest.
8989
```
9090
3. Wait for the CI to do its magic
9191
4. Review the changelog PR
92+
9293
If the release is successful, the HaystackBot will open a pull request to generate the changelog.
9394
Add yourself as the reviewer. If there are any issues, edit the changelog manually.
9495

integrations/pgvector/src/haystack_integrations/document_stores/pgvector/document_store.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ def _execute_sql(
276276
result = cursor.execute(sql_query, params)
277277
except Error as e:
278278
self._connection.rollback()
279-
detailed_error_msg = f"{error_msg}.\nYou can find the SQL query and the parameters in the debug logs."
279+
detailed_error_msg = (
280+
f"{error_msg}. Error: {e!r}. \nYou can find the SQL query and the parameters in the debug logs."
281+
)
280282
raise DocumentStoreError(detailed_error_msg) from e
281283

282284
return result
@@ -314,7 +316,9 @@ async def _execute_sql_async(
314316
result = await cursor.execute(sql_query, params)
315317
except Error as e:
316318
await self._async_connection.rollback()
317-
detailed_error_msg = f"{error_msg}.\nYou can find the SQL query and the parameters in the debug logs."
319+
detailed_error_msg = (
320+
f"{error_msg}. Error: {e!r}. \nYou can find the SQL query and the parameters in the debug logs."
321+
)
318322
raise DocumentStoreError(detailed_error_msg) from e
319323

320324
return result
@@ -795,7 +799,7 @@ def write_documents(self, documents: List[Document], policy: DuplicatePolicy = D
795799
except Error as e:
796800
self._connection.rollback()
797801
error_msg = (
798-
"Could not write documents to PgvectorDocumentStore. \n"
802+
f"Could not write documents to PgvectorDocumentStore. Error: {e!r}. \n"
799803
"You can find the SQL query and the parameters in the debug logs."
800804
)
801805
raise DocumentStoreError(error_msg) from e
@@ -852,7 +856,7 @@ async def write_documents_async(
852856
except Error as e:
853857
await self._async_connection.rollback()
854858
error_msg = (
855-
"Could not write documents to PgvectorDocumentStore. \n"
859+
f"Could not write documents to PgvectorDocumentStore. Error: {e!r}. \n"
856860
"You can find the SQL query and the parameters in the debug logs."
857861
)
858862
raise DocumentStoreError(error_msg) from e

0 commit comments

Comments
 (0)