Add tests and documentation updates for log preview and regex tester hooks
- Add useLogPreview.test.ts with comprehensive test coverage - Add useRegexTester.test.ts with comprehensive test coverage - Update Docs/Tasks.md and Docs/Web-Development.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -488,6 +488,7 @@ if (data.length > MAX_VISIBLE_BANS) { ... }
|
||||
## 11. Error Handling
|
||||
|
||||
- Wrap API calls in `try-catch` inside hooks — components should never see raw exceptions.
|
||||
- **All hook catch blocks must use `handleFetchError` rather than directly calling `setError`.** This ensures auth errors (401/403) are routed to the global session-expiry flow instead of displaying confusing error text in the UI. Use the pattern: `handleFetchError(err, setError, "User-friendly fallback message")`.
|
||||
- Display user-friendly error messages — never expose stack traces or raw server responses in the UI.
|
||||
- Use an **error boundary** (`ErrorBoundary` component) at the page level to catch unexpected render errors.
|
||||
- Log errors to the console (or a future logging service) with sufficient context for debugging.
|
||||
|
||||
Reference in New Issue
Block a user