Skip to content

extractVexErrorData

extractVexErrorData(error): VexErrorStructuredData | undefined

Defined in: packages/core/src/errors.ts:89

Recovers a VexError’s structured { code?, message? } payload from a caught error, regardless of which side of the Convex wire it crossed on.

instanceof VexError only holds for an error constructed directly in-process (e.g. a unit test, or code that never crosses Convex’s client/server boundary) — a VexError thrown from a Convex function and caught by ANY Convex client (convex/react’s useQuery, convex/nextjs’s fetchQuery) always arrives back as a plain ConvexError (the base class), never the subclass, so this checks instanceof ConvexError instead.

A LOCAL Convex dev server additionally wraps the thrown error’s own .data inside a multi-line diagnostic STRING (a class name, a request id, "Uncaught VexError: {json}", then a stack trace with internal file paths) rather than forwarding the structured .data object directly — confirmed live (a stale ?sort= link hitting Step 6’s UNINDEXED_SORT). This finds the line naming VexError: and parses only the JSON on that one line; the class name, request id, and especially the stack trace’s file paths are NEVER part of the returned payload — callers that forward this to the browser (a server-rendered initialQueryError, Design Decision 9/32) never leak them.

unknown

The caught error.

VexErrorStructuredData | undefined

The structured payload, or undefined when error isn’t a ConvexError at all, or its data doesn’t match either recognized shape.