Skip to content

feat(frontend): add error boundary and recovery screen - #68

Open
malaysiaonelove wants to merge 1 commit into
Vaulty-X:mainfrom
malaysiaonelove:feat/error-boundary-recovery-screen
Open

feat(frontend): add error boundary and recovery screen#68
malaysiaonelove wants to merge 1 commit into
Vaulty-X:mainfrom
malaysiaonelove:feat/error-boundary-recovery-screen

Conversation

@malaysiaonelove

Copy link
Copy Markdown

Summary

Adds Next.js App Router error boundaries so that unexpected client-rendering or API errors no longer leave users on a broken, unhelpful page.

Changes

New files

  • Frontend/src/app/error.tsx — Route-level error boundary. Distinguishes wallet connection errors, API errors, and general errors. Renders a friendly fallback with a retry action, a home link, and wallet-specific troubleshooting tips.
  • Frontend/src/app/global-error.tsx — Root-layout error boundary. Owns the full <html>/<body> as required by Next.js; uses inline critical CSS so it renders even if the CSS bundle failed to load.

Updated files

  • Frontend/src/lib/api.ts — Added WalletConnectionError, WalletNotConnectedError, isWalletError(), and isApiError() helpers. Fixed ApiError prototype chain for reliable instanceof across transpilation.
  • Frontend/src/lib/stellar.tsconnectWallet() and signTransaction() now throw typed errors instead of plain Error.
  • Frontend/src/hooks/useWallet.tserror state is now WalletError | null with a kind: 'wallet' | 'general' discriminator; exposes isWalletConnectionError convenience flag.
  • Frontend/src/app/globals.css — Added .error-boundary-* Tailwind component classes used by error.tsx.
  • Frontend/src/app/page.tsx — Fixed missing 'use client' directive (required for useState/hooks).

Acceptance criteria checklist

  • Renders a friendly fallback page for route-level errors
  • Provides a retry action that resets the failed route (reset() prop)
  • Preserves safe error context without exposing secrets or stack traces (only error.digest shown)
  • Distinguishes wallet connection errors from general application errors
  • Fallback layout is accessible (role="alert", aria-live, focus-visible outlines) and responsive

Closes #65

- Add route-level error boundary (error.tsx) with wallet/API/general
  error discrimination and retry action
- Add root-level error boundary (global-error.tsx) with inline critical
  CSS for resilience when the CSS bundle itself fails
- Add WalletConnectionError and WalletNotConnectedError typed error
  classes to lib/api.ts with isWalletError / isApiError helpers
- Update stellar.ts to throw typed WalletConnectionError instead of
  plain Error
- Update useWallet.ts to surface WalletError { message, kind } so
  callers can distinguish wallet vs general failures
- Add error boundary component classes to globals.css
- Fix missing 'use client' directive in page.tsx

Closes Vaulty-X#65
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.

[Frontend] Add an application error boundary and recovery screen

1 participant