Patterns for preventing errors and helping users recover gracefully.
Prevention > Recovery > Graceful Failure
The best error is the one that never happens. The second best is the one users can easily fix.
What: Limiting input to valid options.
| Technique | Example |
|---|---|
| Input masks | Phone: (___) -_ |
| Dropdowns | Choose from valid options |
| Date pickers | Can't type invalid dates |
| Range limits | min/max on number inputs |
| Character limits | maxlength on text |
| Disabled states | Can't click invalid options |
What: Helping users get it right the first time.
| Technique | Example |
|---|---|
| Inline hints | "Password must be 8+ characters" |
| Examples | "e.g., name@example.com" |
| Format indicators | Showing expected format |
| Real-time validation | Check as user types |
| Autocomplete | Suggest valid values |
What: Verifying destructive or irreversible actions.
Use confirmation dialogs for:
Don't overuse: Confirmation fatigue makes users click through without reading.
| Approach | Pros | Cons |
|---|---|---|
| On blur | Good balance, validates after field | Slight delay |
| On submit | Simple to implement | Errors appear late |
| Real-time | Immediate feedback | Can be annoying |
| Debounced | Good for async checks | Timing tuning needed |
DO:
DON'T:
[What's wrong] + [How to fix it]
Examples:
"Email must include @" → "Enter a valid email (e.g., name@example.com)"
"Password too short" → "Password must be at least 8 characters"
"Username taken" → "This username is taken. Try adding numbers or underscores."
What: Allowing users to reverse their actions.
Soft delete:
Action undo:
Draft preservation:
DO:
DON'T:
What: Communicating system errors to users.
[Icon] [Error Title]
[Clear explanation of what happened]
[What the user can do about it]
[Primary Action] [Secondary Action]
| Type | Tone | Recovery Options |
|---|---|---|
| User error | Helpful, not blaming | Explain how to fix |
| System error | Apologetic | Retry, contact support |
| Network error | Informative | Retry when connected |
| Permission error | Clear | Request access, explain why |
| Bad | Good |
|---|---|
| "Error 500" | "Something went wrong on our end. Please try again." |
| "Invalid operation" | "You don't have permission to delete this. Contact an admin." |
| "Failed" | "Couldn't save your changes. Check your connection and try again." |
| "Null pointer exception" | "Something unexpected happened. Our team has been notified." |
DO:
DON'T:
What: Preventing data loss through automatic preservation.
| Strategy | Best For |
|---|---|
| Continuous | Text editors, forms (debounced) |
| On change | Settings, toggles |
| On blur | Form fields |
| Periodic | Long-form content (every 30-60s) |
| Before navigation | Forms with unsaved changes |
DO:
DON'T:
[Modal]
"You have unsaved changes"
If you leave, your changes will be lost.
[Leave anyway] [Stay and save]
What: Maintaining functionality when things go wrong.
| Failure | Graceful Response |
|---|---|
| Network down | Show cached data, queue actions |
| Feature fails | Disable feature, don't crash |
| Image fails | Show placeholder |
| Third-party down | Fallback or skip gracefully |
| Timeout | Auto-retry, then explain |
DO:
DON'T:
| Area | Techniques Applied |
|---|---|
| ☐ Input constraints (masks, limits) | |
| ☐ Guidance before errors occur | |
| ☐ Confirmation for destructive actions | |
| ☐ Appropriate validation timing | |
| ☐ Clear, actionable error messages | |
| ☐ Undo for reversible actions | |
| ☐ Autosave for data preservation | |
| ☐ Graceful handling of system errors | |
| ☐ Recovery options always available |