Skip to content

AbortException

Defined in: gadgets/exceptions.ts:143

Exception thrown when gadget execution is aborted.

Gadgets can throw this exception when they detect the abort signal has been triggered. This is typically used via the throwIfAborted() helper method on the Gadget base class.

class LongRunningGadget extends Gadget({
name: 'LongRunning',
description: 'Performs a long operation with checkpoints',
schema: z.object({ data: z.string() }),
}) {
async execute(params: this['params'], ctx: ExecutionContext): Promise<string> {
// Check at key points - throws AbortException if aborted
this.throwIfAborted(ctx);
await this.doPartOne(params.data);
this.throwIfAborted(ctx);
await this.doPartTwo(params.data);
return 'completed';
}
}
  • Error

new AbortException(message?): AbortException

Defined in: gadgets/exceptions.ts:144

string

AbortException

Error.constructor