Skip to content

EngineError

Defined in: packages/engine/src/errors/EngineError.ts:97

The engine’s structured error type. Still a real Error subclass (so throw/catch/instanceof Error all keep working exactly as before), but now every field except the removed severity/recovery pair is something real code reads.

  • Error
new EngineError(category, init): EngineError;

Defined in: packages/engine/src/errors/EngineError.ts:119

ParameterType
categoryErrorCategory
initEngineErrorInit

EngineError

Error.constructor
readonly category: ErrorCategory;

Defined in: packages/engine/src/errors/EngineError.ts:98


readonly optional cause?: unknown;

Defined in: packages/engine/src/errors/EngineError.ts:117

Set explicitly (not via super(message, {cause})). This repo’s tsconfig.json targets ES6/ES5-ES7 lib, which predates TypeScript’s ES2022 Error constructor cause-option overload. Error.prototype.cause is still a real runtime feature in every target this engine actually runs in (Node 16.9+, all evergreen browsers, Electron/Obsidian’s bundled Chromium) regardless of the TS lib target used to type-check against it, assigning it directly gets the same Node-printer/logger interop with no build-config change needed.


readonly code: string;

Defined in: packages/engine/src/errors/EngineError.ts:99


readonly optional context?: Record<string, unknown>;

Defined in: packages/engine/src/errors/EngineError.ts:105


readonly optional expected?: string;

Defined in: packages/engine/src/errors/EngineError.ts:100


readonly optional found?: string;

Defined in: packages/engine/src/errors/EngineError.ts:101


message: string;

Defined in: docs/node_modules/typescript/lib/lib.es5.d.ts:1075

Error.message

name: string;

Defined in: docs/node_modules/typescript/lib/lib.es5.d.ts:1074

Error.name

readonly recoverable: boolean;

Defined in: packages/engine/src/errors/EngineError.ts:103


readonly optional span?: SourceSpan;

Defined in: packages/engine/src/errors/EngineError.ts:104


optional stack?: string;

Defined in: docs/node_modules/typescript/lib/lib.es5.d.ts:1076

Error.stack

readonly optional suggestion?: string;

Defined in: packages/engine/src/errors/EngineError.ts:102


readonly timestamp: Date;

Defined in: packages/engine/src/errors/EngineError.ts:106


static stackTraceLimit: number;

Defined in: 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.

Error.stackTraceLimit
causeChain(): unknown[];

Defined in: packages/engine/src/errors/EngineError.ts:143

Walk .cause repeatedly, collecting the full chain (this error first).

unknown[]


format(): string;

Defined in: packages/engine/src/errors/EngineError.ts:165

Rust/Go-style multi-line renderer, the NEW thing a host/CLI/test reaches for when it wants the full, verbose picture, as distinct from .message (kept short and stable for existing assertions). Example:

error[WEATHER_EXPECTED_CITY]: Expected a city name after "weather in"
expected: a city name
found: end of expression
suggestion: e.g. "weather in London"

string


isFatal(): boolean;

Defined in: packages/engine/src/errors/EngineError.ts:138

!recoverable. See EngineErrorInit.recoverable’s doc comment for what this actually gates (message framing/telemetry, not whether evaluation continues).

boolean


toJSON(): Record<string, unknown>;

Defined in: packages/engine/src/errors/EngineError.ts:173

Record<string, unknown>


static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/@types/node/globals.d.ts:51

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();
ParameterType
targetObjectobject
constructorOpt?Function

void

Error.captureStackTrace

static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/@types/node/globals.d.ts:55

ParameterType
errError
stackTracesCallSite[]

any

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Error.prepareStackTrace