feat: implement structured exception classes with error codes and sug…#3279
Conversation
|
@deshraj just following up here :) happy to make improvements/edits |
|
@bkidd1 Can you resolve merge conflicts? |
parshvadaftari
left a comment
There was a problem hiding this comment.
These are specifically for client. Can you add for the OSS as well? I see multiple exception handling class which can be used for OSS
…gestions - Replace generic APIError with specific exception types (AuthenticationError, RateLimitError, ValidationError, NetworkError, etc.) - Add comprehensive error context with error codes, suggestions, and debug info - Implement HTTP status code to exception mapping for automatic error classification - Update api_error_handler decorator to use new structured exceptions - Add 57 comprehensive tests covering all exception scenarios - Update client method docstrings to reference specific exception types - Maintain backward compatibility with deprecated APIError class - Enable better error recovery patterns and user feedback Resolves: mem0ai#3270
579d5cd to
a572b48
Compare
|
@bkidd1 Can you see for the failing tests? Thanks |
- Remove unused imports that were only referenced in docstrings - Add back NetworkError import to utils.py (required for actual code usage) - Maintain clean, production-ready code with comprehensive test coverage - All tests passing: 40/40 exception tests, 17/17 client utils tests - Ready for CI validation and merge Resolves linting issues while preserving all structured exception functionality
- Add 6 new OSS-specific exception classes: VectorStoreError, GraphStoreError, EmbeddingError, LLMError, DatabaseError, DependencyError - Update OSS memory operations to use structured exceptions instead of generic ValueError - Replace ValueError with Mem0ValidationError in main.py with rich context - Add comprehensive docstrings to OSS methods referencing structured exceptions - Add 11 comprehensive tests for OSS exception handling - All tests passing: 68/68 total tests (40 + 11 + 17) This extends the structured exception system to cover both client and OSS use cases, providing consistent error handling across the entire Mem0 ecosystem. Resolves: mem0ai#3270
|
@parshvadaftari fixed errors and added OSS! |
…gestions - Add comprehensive exception hierarchy with MemoryError base class - Implement specific exceptions: AuthenticationError, RateLimitError, ValidationError, etc. - Add OSS-specific exceptions: VectorStoreError, GraphStoreError, EmbeddingError, etc. - Update client docstrings to reference new exception types - Update memory operations to use structured exceptions - Remove unused imports to fix linting errors - Remove extensive test files to keep PR focused on core functionality
|
@parshvadaftari my bad, i didn't run ruff/isort correctly the previous commit (and i had to remove leftover test file) but it should be clean now |
|
@bkidd1 No worries, I hope the tests will pass. |
|
@parshvadaftari i see everything passed but build_embedchain was skipped. do i need to fix something for this to run? lmk :) |
|
@bkidd1 Thanks for the PR, no need to fix anything. Thank you for the contribution |
Summary
Replace generic APIError with specific exception types (AuthenticationError, RateLimitError, ValidationError, NetworkError, etc.)
Resolves: #3270
Description
This PR implements structured exception classes to replace the generic
APIErrorwith specific, actionable exceptions that provide better context for debugging and user feedback. The implementation enables developers to implement proper error recovery patterns, show meaningful errors to users, and improves monitoring capabilities.Key improvements:
MemoryErrorExample usage:
Fixes #3270
Type of change
How Has This Been Tested?
Test execution:
hatch run dev_py_3_11:pytest tests/test_exceptions.py tests/test_client_utils.py -v # Result: 57 passed, 0 failedMulti-Python version testing:
Checklist:
Maintainer Checklist