refactor: Centralize error handling across components with TDD#4
Merged
Conversation
Extract duplicate error handling patterns into a single utility function, reducing code duplication and improving maintainability. Changes: - Create error-handler.js utility with handleTransactionError function - Add comprehensive test coverage (20 tests, all passing) - Replace 400+ lines of duplicate error handling in 11 components: * CreateNewAssistant.js (2 catch blocks) * CreateNewBridge.js (1 catch block) * DeployNewOracle.js (1 catch block) * Deposit.js (5 catch blocks) * Withdraw.js (1 catch block) * Challenge.js (2 catch blocks) * WithdrawSuccessFee.js (1 catch block) * WithdrawManagementFee.js (1 catch block) * AssignNewManager.js (1 catch block) - Update CLAUDE.md with correct test command parameters - Suppress console.error during tests for cleaner output Benefits: - 335 lines removed (401 deletions, 66 insertions) - Consistent error handling across all transaction operations - Better UX: longer toast duration for non-user errors - Centralized maintenance: single source of truth for error handling Test coverage: 142/142 tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
Extract duplicate error handling patterns into a centralized utility function, eliminating 335 lines of duplicate code across 11 component files while improving consistency and maintainability.
Key Changes
src/utils/error-handler.jswithhandleTransactionErrorfunctionComponents Updated
CreateNewAssistant.js- 2 catch blocks simplifiedCreateNewBridge.js- 1 catch block simplifiedDeployNewOracle.js- 1 catch block simplifiedDeposit.js- 5 catch blocks simplifiedWithdraw.js- 1 catch block simplifiedChallenge.js- 2 catch blocks simplifiedWithdrawSuccessFee.js- 1 catch block simplifiedWithdrawManagementFee.js- 1 catch block simplifiedAssignNewManager.js- 1 catch block simplifiedNewClaim.js- Already using utilities ✓Expatriation.js- Already using utilities ✓Benefits
Error Types Handled
Test Plan
pnpm test -- --no-watch --passWithNoTests --watchAll=falseDocumentation
CLAUDE.mdwith correct test command parameters for CI/automated testingScreenshots/Evidence
🤖 Generated with Claude Code