feat: Add Better Error Messages#49
Merged
Merged
Conversation
Implement enhanced error messages with context and helpful suggestions. Features: - NotFoundException with similar service suggestions (Levenshtein) - CircularReferenceException with full dependency chain visualization - InvalidBindingException with detailed requirements and examples - ResolveDependenciesTreeException with dependency chain context - DependencyChain utility for tracking resolution path - Helpful hints and multiple solution suggestions for each error Improvements: - Service suggestions use Levenshtein distance for typo detection - Full dependency chain visualization for circular references - Detailed binding validation with requirements - Context-aware error messages with actionable solutions - Added getAvailableServices() helper for suggestion generation - Added getAll() method to ProviderStorage Tests: 130 tests (+5), 236 assertions (+21) Psalm: No errors (99.91% type coverage) php-cs-fixer: All files formatted
Add comprehensive unit and functional tests for all new features. New unit tests: - 21 tests for DependencyChain (100% coverage) * push/pop operations * reset functionality * toString, has, isEmpty, getDepth, getCurrent * Complex scenarios with multiple operations - 2 tests for ProviderStorage::getAll() New functional tests (6): - NotFoundException with no similar services - NotFoundException using Levenshtein for suggestions - CircularReferenceException with empty chain - Multiple suggestions sorted by distance - Container getAvailableServices includes all types Coverage improvements: - DependencyChain: 100% method coverage - ProviderStorage::getAll(): 100% coverage - All Exception classes: enhanced branch coverage - NotFoundException: Levenshtein algorithm paths covered - CircularReferenceException: both chain paths covered Total: 156 tests (+26), 278 assertions (+42) Psalm: No errors (99.91% type coverage) php-cs-fixer: All files formatted
Add comprehensive unit tests for Exception classes and functional tests for all error message scenarios and edge cases. New unit tests for Exception classes (17 tests): - NotFoundException: all parameter combinations (with/without chain, with/without suggestions) - CircularReferenceException: with and without chain - InvalidBindingException: full message format - ResolveDependenciesTreeException: with/without chain, with previous exception - Levenshtein distance algorithm for suggestions - Suggestion limiting to 3 items - All exceptions contain actionable hints New functional tests (8 tests): - NotFoundException with chain - CircularReferenceException with chain - Invalid binding scenarios (non-interface, not implemented, not extended) - Partial match suggestions - Multiple binding errors - Message format consistency Coverage improvements: - All Exception classes: 100% branch coverage - NotFoundException suggestion algorithm: all paths covered - CircularReferenceException: both with/without chain paths - InvalidBindingException: all message parts covered - ResolveDependenciesTreeException: all parameter combinations Total: 177 tests (+21), 355 assertions (+77) Psalm: No errors (99.91% type coverage) php-cs-fixer: All files formatted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement enhanced error messages with context and helpful suggestions.
Features:
Improvements:
Tests: 130 tests (+5), 236 assertions (+21)
Psalm: No errors (99.91% type coverage)
php-cs-fixer: All files formatted