Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom exceptions for better error-handling #46

Merged
merged 7 commits into from
May 31, 2024

Conversation

willtai
Copy link
Contributor

@willtai willtai commented May 28, 2024

Description

This PR adds custom exceptions to replace the usage of ValueError in various places as they were unambiguous and not informative to the user. Here is a way to think about the added exceptions:

  • Retriever-related exceptions:
    • RetrieverInitializationError: used in __init__() method of retrievers.
    • SearchValidationError: used in .search() method of retrievers.
    • FilterValidationError: used in validation of fields for metadata filtering.
    • EmbeddingRequiredError: used when an embedder is required for the retriever.
    • RecordCreationError: used when returning VectorSearchRecord. This will probably change with Retriever results #45
  • Database-related exceptions:
    • Neo4jIndexError: Used for index handling methods
    • Neo4jVersionError: Used when Neo4j version does not meet minimum requirements

Additionally, new types are specified for the WeaviateNeo4jRetriever to be used for data validation. This enables it to raise exceptions similarly to the Neo4j retrievers.

The documentation is updated to include the errors.

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation update
  • Project configuration change

Complexity

Complexity: Low

How Has This Been Tested?

  • Unit tests
  • E2E tests
  • Manual tests

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • Unit tests have been updated
  • E2E tests have been updated
  • Examples have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed

@willtai willtai changed the title Add custom exceptions for Retrievers Add custom exceptions for better error-handling May 28, 2024
@willtai willtai force-pushed the willtai/use-exceptions-for-error-handling branch from d5bb2a1 to 5ea11c9 Compare May 29, 2024 10:05
@willtai willtai marked this pull request as ready for review May 29, 2024 10:07
@willtai willtai requested review from stellasia, team-gen-ai and a team and removed request for stellasia and team-gen-ai May 29, 2024 10:08
@willtai willtai force-pushed the willtai/use-exceptions-for-error-handling branch from 18a59cd to a035b00 Compare May 29, 2024 10:16
@willtai
Copy link
Contributor Author

willtai commented May 29, 2024

@CodiumAI-Agent /update_changelog

@CodiumAI-Agent
Copy link

Changelog updates: 🔄

2024-05-29

Added

  • Introduced custom exceptions for improved error handling, including RetrieverInitializationError, SearchValidationError, FilterValidationError, EmbeddingRequiredError, RecordCreationError, Neo4jIndexError, and Neo4jVersionError.
  • Added new types for WeaviateNeo4jRetriever to support data validation and exception handling.

Changed

  • Replaced ValueError with custom exceptions across various modules for clearer and more specific error messages.

Fixed

  • Updated documentation to include new custom exceptions.

to commit the new content to the CHANGELOG.md file, please type:
'/update_changelog --pr_update_changelog.push_changelog_changes=true'

@willtai willtai requested a review from stellasia May 30, 2024 15:01
@willtai willtai requested review from stellasia and a team May 31, 2024 09:13
Copy link
Contributor

@stellasia stellasia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! (just double check the print in my comments above if you can, the rest is very minor)

@willtai willtai merged commit d8fe490 into main May 31, 2024
9 checks passed
@willtai willtai deleted the willtai/use-exceptions-for-error-handling branch May 31, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants