Skip to content

CustomErrorDefinition<ParameterSchema> ​

ts
type CustomErrorDefinition<ParameterSchema> = object;

An error the AI may pick as its outcome, constructed from a parameter it supplies.

Type Parameters ​

ParameterSchema ​

ParameterSchema extends Schema = Schema

Properties ​

errorConstructor ​

ts
errorConstructor: (param) => Error;

Will be called with a parameter matching the errorParameterSchema.

Parameters ​

param ​

SchemaInfer<ParameterSchema>

Returns ​

Error


description? ​

ts
optional description?: string;

Optional description for the AI to understand when to return this error.


errorParameterSchema? ​

ts
optional errorParameterSchema?: ParameterSchema;

Zod or JSON Schema describing the error constructor parameter type. Omit it for an error constructed without one.


propagate? ​

ts
optional propagate?: boolean;

Whether this error propagates out of trypatch. When false, it is logged and the decorated method rethrows its original error instead.

Default Value ​

false