Skip to main content

Errors and Failures

Understand the shared Convex error categories and who owns recovery.

Better Convex Nuxt exposes one public call error across client composables and server helpers: ConvexCallError.

Error kinds

KindMeaningTypical owner of recovery
authenticationRequired identity is missing, token exchange failed with auth status, or identity changed during a callAuth UI or operation caller
transportNetwork, timeout, abort, malformed response, or library-owned HTTP boundary failureRetry/offline UI or operator
serverA structured Convex application/function errorApplication workflow
unknownNo stable mechanical classification is availableFallback handling and diagnostics

There is no generic validation kind. The module does not infer categories from message text.

Throwing and safe calls

Mutation and action wrappers are callable. Normal calls reject with ConvexCallError:

ts
const save = useConvexMutation(api.projects.update)

try {
  await save({ projectId, name })
} catch (error) {
  const callError = normalizeConvexError(error)
  reportFailure(callError.kind)
}

Use .safe() when the result belongs in normal control flow:

ts
const result = await save.safe({ projectId, name })

if (!result.ok) {
  formError.value = result.error
}

Both styles use the same error contract.

Domain meaning belongs to the application

A Convex function can throw structured ConvexError data such as:

ts
throw new ConvexError({
  code: 'PROJECT_ARCHIVED',
  message: 'Archived projects cannot be edited',
})

The module classifies this as server and preserves structured data. Your application decides that PROJECT_ARCHIVED disables editing or redirects elsewhere.

Do not parse the display message to discover business meaning.

Serialized errors

SSR errors cross the Nuxt payload as a public serialized shape. The client revives that shape as ConvexCallError.

The runtime-only cause is deliberately excluded from JSON, structured clone, SSR HTML, and normal inspection. Credentials and raw upstream responses must never be copied into public fields.

Retry is contextual

  • Retry a transient transport failure when the operation is safe to repeat.
  • Do not retry authentication failures until auth state changes.
  • Let the product workflow decide whether a server error is retryable.
  • Do not retry unknown mutation failures blindly; the write may have reached the server.

See error handling for UI patterns and credentials and security for server-boundary controls.