Optionalsubtype: stringOptionalerrors: string[]OptionalcauseOptional ReadonlyerrorsReadonlyexitReadonlysignalOptionalstackReadonlystderrOptional ReadonlysubtypeStaticstackThe 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.
StaticcaptureCreates 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();
OptionalconstructorOpt: FunctionStaticprepare
A Claude Code CLI invocation that failed: it exited non-zero, died on a signal, or fielded
is_error: trueon its terminalresultenvelope. Carries the raw exit status and stderr AND the CLI's own structured failure fields off the terminalresultenvelope:subtype— the envelope's failure class, the CLI's machine-readable label for what went wrong (e.g."error_during_execution").errors— theerrors[]the CLI fielded on that envelope: its structured error strings (e.g."No conversation found with session ID: <id>"for a stale--resume). A genuine failure (bad auth, rate limit, unknown model) surfaces as this class; a vanished--resumesession surfaces as the LostSessionError subclass, so a caller can branch oninstanceof LostSessionErrorrather than string-matching the message.SECURITY —
stderrand every entry oferrors[]are UNREDACTED CLI output and may echo sensitive detail (env values, a rejected key);messageembedserrors[](or, when the envelope carried none,stderr).stderr,errors, andsubtypeare all enumerable (readonlyctor params), so they also appear inJSON.stringify(error). Do not log them verbatim to shared/public sinks; redact or drop before a trusted boundary. Note too thatmessageis exported to tracing automatically: on a failedcall()underscenario.run(...), LangWatch records it viarecordException/setStatuswith no redaction and no opt-out (systemic fix tracked in #754), so any sensitive CLI output carried in it reaches your configured tracing sink on every failed turn.