Title: Export a guard for `VoidActionError` at every status · Issue #714 · voidzero-dev/void · GitHub
Open Graph Title: Export a guard for `VoidActionError` at every status · Issue #714 · voidzero-dev/void
X Title: Export a guard for `VoidActionError` at every status · Issue #714 · voidzero-dev/void
Description: Summary Follow-up to #680, as #691 suggested ("that can be a separate change"). Since 1.6.0, a 4xx action error's message is the server's text, thanks for that. #680's other ask is still open: a guard that recognises a VoidActionError at...
Open Graph Description: Summary Follow-up to #680, as #691 suggested ("that can be a separate change"). Since 1.6.0, a 4xx action error's message is the server's text, thanks for that. #680's other ask is still open: a gu...
X Description: Summary Follow-up to #680, as #691 suggested ("that can be a separate change"). Since 1.6.0, a 4xx action error's message is the server's text, thanks for that. #680's other a...
Opengraph URL: https://github.com/voidzero-dev/void/issues/714
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Export a guard for `VoidActionError` at every status","articleBody":"### Summary\n\nFollow-up to #680, as [#691](https://github.com/voidzero-dev/void/pull/691) suggested (\"that can be a separate change\"). Since 1.6.0, a 4xx action error's `message` is the server's text, thanks for that. #680's other ask is still open: a guard that recognises a `VoidActionError` at every status.\n\nThe [actions guide](https://github.com/voidzero-dev/void/blob/main/docs/guide/pages-routing/actions-and-forms.md) says 401, 403 and 5xx are thrown, and to \"handle them with your framework's error boundary\". But the only guard Void exports, `isCallSiteActionError()`, is `false` for exactly those statuses. So an error boundary can't tell an action error from any other error without reproducing Void's internals.\n\n### Reproduction\n\n```ts\n// pages/notes.server.ts\nimport { HTTPException } from 'hono/http-exception';\nimport { defineHandler } from 'void';\n\nexport const action = defineHandler(async (c) => {\n const status = Number(c.req.query('status'));\n throw new HTTPException(status as 403, { message: 'You can vote once your account is a day old' });\n});\n```\n\n```ts\n// pages/notes.tsx\nimport { isCallSiteActionError } from 'void/pages-client';\n\ntry {\n await action(`/notes?status=${status}`, { data: {} });\n} catch (error) {\n isCallSiteActionError(error); // false for 401, 403 and 5xx\n}\n```\n\n| Status | `action()` | `error.name` | `isCallSiteActionError()` |\n| ------ | ---------- | ----------------- | ------------------------- |\n| 409 | returns | `VoidActionError` | `true` |\n| 401 | throws | `VoidActionError` | `false` |\n| 403 | throws | `VoidActionError` | `false` |\n| 500 | throws | `VoidActionError` | `false` |\n\n### Why it matters\n\n- **The boundary the docs point to has no guard.** It has to tell an action error from a render bug to show a 403's message, send a 401 to login, or show a generic message for a 500.\n- **Every app copies the guard's internals.** `instanceof VoidActionError` isn't reliable when the class is bundled more than once, which is why `isCallSiteActionError()` checks `error.name`. Apps do the same by hand, relying on a class name the docs never mention.\n- **Neither exported helper is documented.** `isCallSiteActionError()` and `categorizeActionError()` are exported from `void/pages-client` but don't appear in the guide or the API reference.\n\n### Proposal\n\n1. Export `isVoidActionError()` next to `isCallSiteActionError()`, true for every status:\n\n ```ts\n export function isVoidActionError(error: unknown): error is VoidActionError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'name' in error &&\n error.name === 'VoidActionError' &&\n 'status' in error &&\n typeof error.status === 'number'\n );\n }\n\n export function isCallSiteActionError(error: unknown): error is VoidActionError {\n return isVoidActionError(error) && categorizeActionError(error.status) === 'callSite';\n }\n ```\n\n2. Document both guards in the actions guide, next to the paragraph on thrown errors.\n\n### Prior art\n\n- **React Router:** `isRouteErrorResponse(error)` recognises a thrown response in an error boundary, at any status.\n- **SvelteKit:** `isHttpError(error, status?)` recognises an `error()` at any status, or a given one.\n\n### Workaround\n\n```ts\n// By name: instanceof fails across bundled copies.\nexport function isActionError(error: unknown): error is VoidActionError {\n return error instanceof Error && error.name === 'VoidActionError';\n}\n```\n\n### Environment\n\n- `void` 1.6.1\n- `@void/react` 1.6.1\n","author":{"url":"https://github.com/karthickeyan-dev","@type":"Person","name":"karthickeyan-dev"},"datePublished":"2026-11-04T15:48:55Z","url":"https://github.com/voidzero-dev/void/issues/714"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:756039d4-446e-d44a-389a-7515dcf028eb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA06:243829:1ED496:2A619D:6AFBFFC2 |
| html-safe-nonce | 289d2fee47bc8c73579e6ac80bdaeee5d0d209ddd816b1fa3fa4902b32cbf603 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTA2OjI0MzgyOToxRUQ0OTY6MkE2MTlEOjZBRkJGRkMyIiwidmlzaXRvcl9pZCI6IjU4Mjc1MTc5NjgxMDI5ODE1NzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 01a8414eca2b2c4f6671e9c635df9a21631cb43f449a8b276c11e17afc8104be |
| hovercard-subject-tag | issue:6206236058 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/714/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0e6c5e89c5f700ead7efbb30ab35befb724392185b682c6d54d7c0b8f1149768/voidzero-dev/void/issues/714 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0e6c5e89c5f700ead7efbb30ab35befb724392185b682c6d54d7c0b8f1149768/voidzero-dev/void/issues/714 |
| og:image:alt | Summary Follow-up to #680, as #691 suggested ("that can be a separate change"). Since 1.6.0, a 4xx action error's message is the server's text, thanks for that. #680's other ask is still open: a gu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | karthickeyan-dev |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| turbo-cache-control | no-preview |
| go-import | github.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git |
| octolytics-dimension-user_id | 149750581 |
| octolytics-dimension-user_login | voidzero-dev |
| octolytics-dimension-repository_id | 1164437080 |
| octolytics-dimension-repository_nwo | voidzero-dev/void |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1164437080 |
| octolytics-dimension-repository_network_root_nwo | voidzero-dev/void |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width