Skip to main content

Class: Z2FViteError

Defined in: packages/vite/src/errors.ts:68

Structured error thrown by the @zod-to-form/vite plugin.

Every error carries a stable code (see Z2FViteErrorCode) and an optional file location. During vite dev the plugin catches these and reports them via the dev-server error overlay. During vite build they propagate and abort the build with the code as a breadcrumb.

Use When​

  • Catching plugin errors in integration tests: expect(fn).toThrow(/Z2F_VITE_/))
  • Wrapping plugin calls in error handlers that need to branch on specific error codes

Avoid When​

  • General application error handling — this class is specific to plugin-level failures; use standard Error or your own error hierarchy for application errors

Never​

  • NEVER compare error.message to detect error type — the [Z2F_VITE_...] prefix in the message is an implementation detail and may change; FIX: always check error.code (e.g. error.code === 'Z2F_VITE_SCHEMA_NOT_FOUND') for stable, semver-stable matching

Extends​

  • Error

Constructors​

Constructor​

new Z2FViteError(code, message, location?): Z2FViteError

Defined in: packages/vite/src/errors.ts:72

Parameters​

code​

Z2FViteErrorCode

message​

string

location?​

Z2FViteErrorLocation

Returns​

Z2FViteError

Overrides​

Error.constructor

Properties​

cause?​

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24

Inherited from​

Error.cause


code​

readonly code: Z2FViteErrorCode

Defined in: packages/vite/src/errors.ts:69


location?​

readonly optional location?: Z2FViteErrorLocation

Defined in: packages/vite/src/errors.ts:70


message​

message: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075

Inherited from​

Error.message


name​

name: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074

Inherited from​

Error.name


stack?​

optional stack?: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from​

Error.stack


stackTraceLimit​

static stackTraceLimit: number

Defined in: node_modules/.pnpm/@types+node@26.6.1/node_modules/@types/node/globals.d.ts:67

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from​

Error.stackTraceLimit

Methods​

captureStackTrace()​

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: packages/vite/src/errors.ts:105

Captures the current V8 call stack and attaches it to targetObject.stack. Inherited from the built-in Node.js Error class. Documented here so TypeDoc surfaces it as part of the Z2FViteError API.

Parameters​

targetObject​

object

The object on which the stack property is set.

constructorOpt?​

Function

Optional constructor; frames above it are omitted from the trace.

Returns​

void

Overrides​

Error.captureStackTrace


isError()​

static isError(error): error is Error

Defined in: packages/vite/src/errors.ts:93

Returns true when error is an instance of Error. Inherited from the built-in Error class (ES2025). Documented here so TypeDoc surfaces the complete API for Z2FViteError without consumers needing to check the global Error reference.

Parameters​

error​

unknown

The value to test.

Returns​

error is Error

true if error is an Error instance; false otherwise.

Overrides​

Error.isError


prepareStackTrace()​

static prepareStackTrace(err, stackTraces): unknown

Defined in: packages/vite/src/errors.ts:118

Optional hook called by V8 to format the stack trace string. Inherited from the built-in Node.js Error class. When set, it replaces V8's default stack-trace formatter.

Parameters​

err​

Error

The Error instance whose stack is being formatted.

stackTraces​

CallSite[]

The structured stack-trace frames provided by V8.

Returns​

unknown

A formatted stack string (or any value; V8 coerces it via .toString()).

Overrides​

Error.prepareStackTrace