Skip to content

Commit f89f1dc

Browse files
committed
small improvements
1 parent 159c34c commit f89f1dc

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

packages/xl-ai/src/api/formats/base-tools/createAddBlocksTool.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { updateToReplaceSteps } from "../../../prosemirror/changeset.js";
1010
import { RebaseTool } from "../../../prosemirror/rebaseTool.js";
1111
import { Result, streamTool } from "../../../streamTool/streamTool.js";
12+
import { AbortError } from "../../../util/AbortError.js";
1213
import { isEmptyParagraph } from "../../../util/emptyBlock.js";
1314
import { validateBlockArray } from "./util/validateBlockArray.js";
1415

@@ -269,9 +270,7 @@ export function createAddBlocksTool<T>(config: {
269270

270271
for (const step of agentSteps) {
271272
if (abortSignal?.aborted) {
272-
const error = new Error("Operation was aborted");
273-
error.name = "AbortError";
274-
throw error;
273+
throw new AbortError("Operation was aborted");
275274
}
276275
if (options.withDelays) {
277276
await delayAgentStep(step);

packages/xl-ai/src/api/formats/base-tools/createUpdateBlockTool.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { updateToReplaceSteps } from "../../../prosemirror/changeset.js";
1010
import { RebaseTool } from "../../../prosemirror/rebaseTool.js";
1111
import { Result, streamTool } from "../../../streamTool/streamTool.js";
12+
import { AbortError } from "../../../util/AbortError.js";
1213

1314
export type UpdateBlockToolCall<T> = {
1415
type: "update";
@@ -245,9 +246,7 @@ export function createUpdateBlockTool<T>(config: {
245246

246247
for (const step of agentSteps) {
247248
if (abortSignal?.aborted) {
248-
const error = new Error("Operation was aborted");
249-
error.name = "AbortError";
250-
throw error;
249+
throw new AbortError("Operation was aborted");
251250
}
252251
if (options.withDelays) {
253252
await delayAgentStep(step);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class AbortError extends Error {
2+
constructor(
3+
message: string,
4+
options?: { cause?: unknown; aborted?: boolean },
5+
) {
6+
super(message, options);
7+
this.name = "AbortError";
8+
}
9+
}

0 commit comments

Comments
 (0)