Skip to content

feat(pages): export isVoidActionError() to recognize action errors at every status - #715

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
karthickeyan-dev:feat/is-void-action-error
Nov 4, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
karthickeyan-dev:feat/is-void-action-error

Conversation

@karthickeyan-dev

@karthickeyan-dev karthickeyan-dev commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #714

Problem

The actions guide says 401, 403 and 5xx action errors are thrown, and to handle them with an error boundary. The only exported guard, isCallSiteActionError(), is false for exactly those statuses. An app has to check error.name === 'VoidActionError' by hand to tell a failed action from a render bug, because instanceof isn't reliable when the class is bundled more than once.

Change

  • isVoidActionError(error) is true for a VoidActionError at any status and narrows the type. It checks the name and a numeric status, like the existing guard.
  • isCallSiteActionError() now calls isVoidActionError() and keeps its behavior.
  • Both guards and the VoidActionError type are exported from void/pages-client and from @void/react, @void/vue, @void/svelte and @void/solid. The guide already imports action from the adapter packages, so the guards are available from the same place.
Status action() isVoidActionError() isCallSiteActionError()
409 returns true true
401 throws true false
403 throws true false
500 throws true false

Docs

  • Actions guide: after the paragraph on thrown errors, an example that handles a 401 and a 403 with isVoidActionError(), and a sentence on isCallSiteActionError().
  • API reference: both guards are added to the React, Vue, Svelte and Solid runtime tables.

Tests

packages/void/test/unit/action-result.test.ts:

  • isVoidActionError() is true for 401, 403, 409, 422 and 500, and for a structurally equivalent object from another bundled copy.
  • It's false for a plain Error, a missing or non-numeric status, null, and a string.
  • isCallSiteActionError() is true for 409 and 422, and false for 401, 403, 500 and a plain Error.

Verification

On Node 24.22.1 (.node-version):

$ vp test run packages/void/test/unit/action-result.test.ts
 Tests  28 passed (28)
$ vp test run packages/react/test/integration/react-pages-client.test.ts packages/vue/test/integration/vue-pages-client.test.ts packages/svelte/test/integration/svelte-pages-client.test.ts packages/solid/test/integration/solid-pages-playground.test.ts
 Tests  245 passed (245)
$ vp test run
 Test Files  774 passed | 1 skipped (775)
      Tests  15953 passed | 35 skipped (15988)
$ vp run check:sdk   # 12/12 successful
$ vp check           # format and lint clean
$ vp run build:docs  # no dead links

🤖 Generated with Claude Code

… every status

Closes voidzero-dev#714

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cpojer
cpojer merged commit be9b568 into voidzero-dev:main Nov 4, 2026
2 checks 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.

Export a guard for VoidActionError at every status

2 participants