Class ContinuationInterruptedError

Thrown when Interactions automatic continuation fails after progress.

interactions.create() with automatic_continuation enabled (the default) may make several requests ("hops"), each one resuming the decode from the previous hop's continuation_token. If a hop fails after the server already produced (and billed) output in an earlier hop, or after a resumable checkpoint was reached, this error is thrown instead of the underlying error so the work is not lost. The underlying error is cause.

To resume, pass continuationToken as continuation_token to interactions.create(): with store enabled (the default), also pass interactionId as previous_interaction_id and no input; with store: false, resend the original input.

Hierarchy

  • Error
    • ContinuationInterruptedError

Constructors

Properties

cause: unknown

The underlying error (the failed hop's API or transport error).

continuationIds: string[]

The ids of every hop created during the call, in order.

continuationToken: undefined | string

The latest resumable continuation token. For streams this may be a mid-hop checkpoint: resuming from it re-generates any output yielded after the checkpoint.

interactionId: undefined | string

The id of the interaction that issued continuationToken (the value to send as previous_interaction_id), or undefined if unknown or unstored (store: false).

message: string
name: string
partialInteraction: unknown

For unary calls, the interaction merged from the hops that completed (status requires_continuation, with the resumable continuation_token), or undefined if no hop completed. Always undefined for streams, whose events were already yielded.

stack?: 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.

Methods

  • 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