Skip to content

fix(wallet): structured error handling with WalletError class and err…#326

Merged
Smartdevs17 merged 1 commit into
Smartdevs17:mainfrom
Sendi0011:feature/issue-41-wallet-error-handling
Apr 28, 2026
Merged

fix(wallet): structured error handling with WalletError class and err…#326
Smartdevs17 merged 1 commit into
Smartdevs17:mainfrom
Sendi0011:feature/issue-41-wallet-error-handling

Conversation

@Sendi0011
Copy link
Copy Markdown
Contributor


fix(wallet): structured error handling in walletService (#41)

Problem

Errors across walletService.ts were either swallowed with console.error and re-thrown raw, or thrown as plain Error objects with no context — leaving users with generic messages and no path to recovery.

What changed

  • Added WalletError class with code, userMessage, and recovery fields — callers can now branch on error.code and surface error.recovery directly in the UI
  • Added WalletErrorCode enum covering all failure scenarios (NOT_CONNECTED, USER_REJECTED, NETWORK_MISMATCH, BALANCE_FETCH_FAILED, GAS_ESTIMATION_FAILED, STREAM_CREATION_FAILED, APPROVAL_FAILED)
  • Added ErrorRateTracker (exported as errorTracker) to record error frequency by code — plug into your monitoring layer via errorTracker.getStats()
  • Replaced all raw throw error / console.error + rethrow patterns with a toWalletError helper that logs full detail for debugging while returning a safe, short user message
  • Covered: getWalletSigner, getTokenBalances, estimateGas, createSuperfluidStream, createSablierStream, approveErc20, estimateApproveGas
  • No sensitive info leaks into user-facing messages

Tests

Updated existing tests to assert on WalletError shape and added new coverage for errorTracker, WalletError cause-stack preservation, and BALANCE_FETCH_FAILED structured error.

Closes #41

…or rate tracking

- Add WalletError class with code, userMessage, and recovery fields
- Add WalletErrorCode enum covering all failure scenarios
- Add ErrorRateTracker to record error frequency by code
- Replace raw throw/console.error patterns with toWalletError helper
- Wrap getTokenBalances, estimateGas, createSuperfluidStream,
  createSablierStream, approveErc20, estimateApproveGas, getWalletSigner
- User-facing messages are short and safe (no sensitive info exposed)
- Recovery hints provided where actionable
- Update tests to assert on WalletError shape, code, and recovery
- Add coverage for errorTracker and WalletError cause stack

Closes Smartdevs17#41
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 25, 2026

@Sendi0011 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Smartdevs17 Smartdevs17 merged commit 2b2bf27 into Smartdevs17:main Apr 28, 2026
3 of 18 checks passed
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.

🔧 Improve error handling in walletService

2 participants