@langwatch/scenario
    Preparing search index...

    Class ClaudeCodeCliError

    A Claude Code CLI invocation that failed: it exited non-zero, died on a signal, or fielded is_error: true on its terminal result envelope. Carries the raw exit status and stderr AND the CLI's own structured failure fields off the terminal result envelope:

    • subtype — the envelope's failure class, the CLI's machine-readable label for what went wrong (e.g. "error_during_execution").
    • errors — the errors[] 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 --resume session surfaces as the LostSessionError subclass, so a caller can branch on instanceof LostSessionError rather than string-matching the message.

    SECURITY — stderr and every entry of errors[] are UNREDACTED CLI output and may echo sensitive detail (env values, a rejected key); message embeds errors[] (or, when the envelope carried none, stderr). stderr, errors, and subtype are all enumerable (readonly ctor params), so they also appear in JSON.stringify(error). Do not log them verbatim to shared/public sinks; redact or drop before a trusted boundary. Note too that message is exported to tracing automatically: on a failed call() under scenario.run(...), LangWatch records it via recordException/setStatus with 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.

    Hierarchy (View Summary)

    Index
    cause?: unknown
    errors?: string[]
    exitCode: number | null
    message: string
    name: string
    signal: Signals | null
    stack?: string
    stderr: string
    subtype?: string
    stackTraceLimit: number

    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.

    • 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();

      Parameters

      • targetObject: object
      • OptionalconstructorOpt: Function

      Returns void