Loading...
Loading...
> User-friendly error messages following the What/Why/How pattern. Helps users recognize, diagnose, and recover from errors.
1import { FormError, commonErrors } from "@/components/ui/form-error"
Unable to save your changes
The server is temporarily unavailable.
How to fix: Please wait a moment and try again.
1<FormError2 what="Unable to save your changes"3 why="The server is temporarily unavailable."4 how="Please wait a moment and try again."5/>
Failed to load data
Network connection was interrupted.
How to fix: Check your internet connection and try again.
1<FormError2 what="Failed to load data"3 why="Network connection was interrupted."4 how="Check your internet connection and try again."5 onRetry={() => handleRetry()}6/>
Payment processing failed
Your card was declined by the payment processor.
How to fix: Verify your card details or try a different payment method.
1<FormError2 what="Payment processing failed"3 why="Your card was declined by the payment processor."4 how="Verify your card details or try a different payment method."5 helpLink="https://example.com/help/payments"6/>
Unable to connect to the server
This might be due to network issues or server maintenance.
How to fix: Check your internet connection and try again.
1import { FormError, commonErrors } from "@/components/ui/form-error";23<FormError {...commonErrors.network} />
Invalid email address
The email format doesn't match our requirements.
How to fix: Enter a valid email like name@example.com
1<FormError {...commonErrors.validation.email} />
Password too weak
Your password doesn't meet security requirements.
How to fix: Use at least 12 characters with uppercase, lowercase, numbers, and symbols.
1<FormError {...commonErrors.validation.password} />
Your session has expired
You've been inactive for too long.
How to fix: Please log in again to continue.
1<FormError {...commonErrors.auth.sessionExpired} />
File too large
The file exceeds the maximum size limit.
How to fix: Choose a file smaller than 10MB or compress it first.
1<FormError {...commonErrors.upload.tooLarge} />
Payment declined
Your card was declined by the payment processor.
How to fix: Check your card details or try a different payment method.
1<FormError2 {...commonErrors.payment.declined}3 onRetry={() => handleRetry()}4 helpLink="https://example.com/help/payments"5/>
1// UX Heuristic #9: Help Users Recognize, Diagnose, and Recover from Errors2//3// Error Message Formula:4// 1. WHAT went wrong (clear, specific)5// 2. WHY it happened (root cause)6// 3. HOW to fix it (actionable steps)7// 4. ACTION to resolve (optional button)89<FormError10 what="What went wrong"11 why="Why it happened"12 how="How to fix it"13 onRetry={handleRetry}14 helpLink="/docs/help"15/>
| Prop | Type | Default | Description |
|---|---|---|---|
| what | string | "Something went wrong" | What went wrong (clear, specific description). |
| why | string | - | Why it happened (root cause explanation). |
| how | string | - | How to fix it (actionable steps for recovery). |
| onRetry | () => void | - | Callback function for retry button. |
| helpLink | string | - | URL to help documentation. |
| className | string | - | Additional CSS classes. |