Skip to content

closes #460 - docs: add error handling guide for React Query hooks#466

Merged
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
samjay8:feat/add-docs
Jun 26, 2026
Merged

closes #460 - docs: add error handling guide for React Query hooks#466
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
samjay8:feat/add-docs

Conversation

@samjay8

@samjay8 samjay8 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #460

This PR adds a contributor guide documenting how to handle API errors consistently in React Query hooks across the codebase.

  • Documents the onError pattern for useMutation and the isError/error approach for useQuery (which dropped onError in v5)
  • Explains when to show a toast (user-initiated mutations, non-blocking errors) vs an inline error state (blocking read failures, 422 field errors) vs SectionErrorBoundary (render-time throws)
  • Covers how to distinguish network errors (status === 0), 4xx client errors (safe to show the API message), and 5xx server errors (use a generic fallback, not the raw server message)
  • Includes a complete worked example showing all three error branches in one hook and the corresponding component-side usage

Files changed

  • docs/error-handling-in-hooks.md - new contributor guide

Test plan

  • Review the guide against the existing ApiError shape in src/services/api.service.ts
  • Confirm the useMutation code example aligns with the React Query v5 API
  • Confirm the useQuery inline-error example aligns with how React Query v5 surfaces errors
  • Check the quick-reference table covers all cases in the acceptance criteria

Documents the standard pattern contributors should follow when writing
new useQuery and useMutation hooks — covering the onError callback
convention, when to show a toast vs inline error vs error boundary,
how to distinguish 4xx client errors from 5xx server errors and network
failures, and a worked example hook that handles all three cases.

Closes accesslayerorg#460
@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@samjay8 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093 Chucks1093 merged commit 27cb9a8 into accesslayerorg:dev Jun 26, 2026
1 check passed
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.

Add docs for how the client handles API errors and what contributors should do in new hooks

2 participants