Jak aplikace zvládá chyby a poskytuje fallback experiences
1. Fail gracefully
- Nikdy white screen of death
- Vždy nějaká UI response
2. Clear messaging
- User ví co se stalo
- Jasná next akce
3. Recovery options
- Retry button kde má smysl
- Alternativní cesta
4. Silent recovery
- Minor errory řešit automaticky
- Retry logic na pozadí
5. Track errors
- Logovat pro debugging
- Monitoring kritických chybProblém: Phaser bundle se nepodaří načíst nebo inicializovat
Fallback:
Static portfolio view:
- Zobraz jméno a bio
- Vypíš všechny dialogy jako text karty
- "Interactive portfolio temporarily unavailable"
- Retry button
- Link na support email
UI:
- Pixel-art error icon
- Friendly message (ne technical jargon)
- Clear call-to-actionTracking:
- Logovat error do backend
- Track: asset URL, browser, error message
Problém: User navštíví neexistující subdomain
Custom 404 page:
Obsah:
- "Portfolio Not Found"
- Friendly message (double-check URL)
- CTA: "Go Home" button
- CTA: "Create Your Own" button
- Help text pro hledání správného URL
Design:
- Pixel-art cat mascot
- Consistent s hlavním designem
- Ne generic Apache 404Problém: Network error, server down, 500 response
Retry Strategy:
Network errors:
- Auto-retry 3× s exponential backoff
- 1s, 2s, 4s delay
Client errors (4xx):
- No retry (bad request, unauthorized)
- Show specific error message
Server errors (5xx):
- Retry 3×
- Show "Server error, try again" messageUser Feedback:
Loading state:
- Spinner nebo loading bar
- "Saving..." message
Error state:
- Toast notification (ne blocking modal)
- Specific error messages:
- 409: "Username already taken"
- 401: "Session expired, log in again"
- 500: "Server error, try again"
- Retry button
Success state:
- Green checkmark toast
- "Saved! ✅" messageProblém: Character sprite nebo background se nenačte
Handling:
Detection:
- Phaser load error event
- Track které assety failnou
Fallback:
- Placeholder sprite (basic colored rectangle)
- Error message overlay
- "Failed to load assets. Please refresh."
- Retry button
Prevention:
- Test all asset URLs při publish
- Fallback CDN (future)Problém: MySQL server nedostupný
503 Maintenance Page:
Obsah:
- "We'll be right back"
- Friendly maintenance message
- Retry button
- Status updates link (Twitter)
- No technical details (user-facing)
Backend:
- Log critical error
- Alert admin (email/SMS)
- Auto-recovery pokud možnéHandling:
Silent fail:
- Analytics NIKDY nesmí shodit app
- Try-catch všude
- Log warning (ne error)
Offline queue:
- Pokud offline, queue events
- Send při reconnectProblém: postMessage mezi iframe a parent selže
Fallback:
Option A:
- Reload iframe s config v query params
- Slower ale funguje
Option B:
- localStorage communication
- Iframe polluje localStorage
User feedback:
- "Preview reloaded" toast
- Seamless experienceProblém: localStorage full nebo disabled
Handling:
Detection:
- Try-catch při save
- Quota exceeded error
Fallback:
- Session storage
- In-memory only (warning user)
- "Unsaved changes" warning při close
User notification:
- "Auto-save unavailable" banner
- Manual save button highlightedFallback:
Detection:
- No touch events po 5s
- Timeout check
Alternative:
- Show keyboard controls hint
- "Use Arrow Keys or WASD"
- Virtual D-pad overlay (future)Frontend logging:
- Global error handler (window.onerror)
- Unhandled promise rejections
- Custom trackError() funkce
Backend logging:
- PHP error_log
- Custom log file: /var/log/pixcard/errors.log
What to log:
- Error type & message
- URL & user agent
- Timestamp
- User ID (pokud logged in)
- Stack trace (dev only)
Future monitoring:
- Sentry (error tracking service)
- Email alerts pro critical errors✅ Game load failure → Static fallback
✅ 404 page → Helpful message + CTA
✅ API errors → Retry logic + toast
✅ Database down → 503 page
✅ Asset load fail → Error message + retry
✅ Global error tracking → Log to backend⏳ Offline mode detection
⏳ Service worker caching
⏳ Error dashboard (admin)
⏳ User bug reports ("Report issue" button)
⏳ Automatic recovery (background retries)✅ Good:
- "Username already taken. Try: johndoe2, j-doe"
- "Portfolio not found. Double-check the URL."
- "Connection error. Check internet and retry."
- "Session expired. Please log in again."
❌ Bad:
- "Error 409"
- "Network request failed"
- "Unexpected token < in JSON"
- "null is not an object"1. Explain what happened (no tech jargon)
2. Suggest next action (retry, go home, contact support)
3. Friendly tone (ne scary)
4. Actionable (button/link pro fix)1. Toast notification
- Success, error, info variants
- Auto-dismiss (3-5s)
- Close button
2. Error boundary (React-like)
- Catch component errors
- Show fallback UI
- Track to monitoring
3. Loading states
- Spinner
- Skeleton screens
- Progress bar (dlouhé operace)
4. Empty states
- "No portfolios yet"
- CTA pro create first
5. Offline banner
- Detect navigator.onLine
- Sticky top banner
- Auto-hide při reconnectNetwork:
- Offline mode (DevTools)
- Slow 3G (throttling)
- Request timeout
Assets:
- Missing sprite files
- Broken image URLs
- Large files (timeout)
API:
- 401, 403, 404, 409, 500 responses
- Network timeout
- Malformed JSON
Database:
- Connection timeout
- Query errors
- Constraint violations
Edge cases:
- localStorage full
- Cookies disabled
- JavaScript disabled (basic fallback)- Architecture → 03-architecture.md
- MVP scope → 05-mvp-scope.md
- UI Components → 10-ui-components-TODO.md
Next: Implementovat error handling systematicky během vývoje