Open
Conversation
Contributor
Collaborator
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste - This is textbook refactoring done right.
Verdict: ✅ Worth merging
Analysis:
Clean DRY refactoring that eliminates 6 identical try/except blocks and 3 identical restart hints. The decorator is simple (no complex nesting), preserves behavior exactly, and makes the code more maintainable. Each handler is now pure happy-path logic, which is easier to read and modify.
Key Insight: This is what refactoring should be - removing duplication with a standard pattern without adding complexity or changing behavior.
No critical issues found. If this module has tests, verify they still pass (though they should, since behavior is preserved).
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.
Replaced 6 identical try/except MCPConfigurationError blocks with a single @_mcp_error_handler decorator, and
extracted the repeated "restart session" message into _print_restart_hint().
Why: Duplicated error handling is a maintenance risk — if the error format, exit code, or styling ever needs to change,
you'd have to update 6 places instead of 1. The decorator makes each handler purely about its happy-path logic, which is easier to read and less prone to inconsistencies.
🚀 Try this PR