mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 03:31:10 +00:00
refactor: dedupe extension error formatting
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type * as Lark from "@larksuiteoapi/node-sdk";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import type { OpenClawPluginApi } from "../runtime-api.js";
|
||||
import { listEnabledFeishuAccounts } from "./accounts.js";
|
||||
import { createFeishuToolClient } from "./tool-account.js";
|
||||
@@ -579,7 +580,7 @@ export function registerFeishuBitableTools(api: OpenClawPluginApi) {
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
return json({ error: err instanceof Error ? err.message : String(err) });
|
||||
return json({ error: formatErrorMessage(err) });
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type * as Lark from "@larksuiteoapi/node-sdk";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import type { OpenClawPluginApi } from "../runtime-api.js";
|
||||
import { listEnabledFeishuAccounts } from "./accounts.js";
|
||||
import { FeishuChatSchema, type FeishuChatParams } from "./chat-schema.js";
|
||||
@@ -181,7 +182,7 @@ export function registerFeishuChatTools(api: OpenClawPluginApi) {
|
||||
return json({ error: `Unknown action: ${String(p.action)}` });
|
||||
}
|
||||
} catch (err) {
|
||||
return json({ error: err instanceof Error ? err.message : String(err) });
|
||||
return json({ error: formatErrorMessage(err) });
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -4,6 +4,7 @@ import { isAbsolute, resolve } from "node:path";
|
||||
import { basename } from "node:path";
|
||||
import type * as Lark from "@larksuiteoapi/node-sdk";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import type { OpenClawPluginApi } from "../runtime-api.js";
|
||||
import { listEnabledFeishuAccounts } from "./accounts.js";
|
||||
import { FeishuDocSchema, type FeishuDocParams } from "./doc-schema.js";
|
||||
@@ -916,7 +917,7 @@ async function createDoc(
|
||||
});
|
||||
requesterPermissionAdded = true;
|
||||
} catch (err) {
|
||||
requesterPermissionError = err instanceof Error ? err.message : String(err);
|
||||
requesterPermissionError = formatErrorMessage(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1549,7 +1550,7 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
|
||||
return json({ error: "Unknown action" });
|
||||
}
|
||||
} catch (err) {
|
||||
return json({ error: err instanceof Error ? err.message : String(err) });
|
||||
return json({ error: formatErrorMessage(err) });
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -1573,7 +1574,7 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) {
|
||||
const result = await listAppScopes(getClient(undefined, ctx.agentAccountId));
|
||||
return json(result);
|
||||
} catch (err) {
|
||||
return json({ error: err instanceof Error ? err.message : String(err) });
|
||||
return json({ error: formatErrorMessage(err) });
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type * as Lark from "@larksuiteoapi/node-sdk";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import type { OpenClawPluginApi } from "../runtime-api.js";
|
||||
import { listEnabledFeishuAccounts } from "./accounts.js";
|
||||
import { encodeQuery, extractReplyText, isRecord, readString } from "./comment-shared.js";
|
||||
@@ -687,7 +688,7 @@ export async function deliverCommentThreadText(
|
||||
console.warn(
|
||||
`[feishu_drive] comment metadata preflight failed ` +
|
||||
`comment=${params.comment_id} file_type=${params.file_type} ` +
|
||||
`error=${error instanceof Error ? error.message : String(error)}`,
|
||||
`error=${formatErrorMessage(error)}`,
|
||||
);
|
||||
isWholeComment = false;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import type { ClawdbotConfig } from "../runtime-api.js";
|
||||
import { resolveFeishuAccount } from "./accounts.js";
|
||||
import { raceWithTimeoutAndAbort } from "./async.js";
|
||||
@@ -126,7 +127,7 @@ function safeJsonStringify(value: unknown): string {
|
||||
return JSON.stringify(value);
|
||||
} catch (error) {
|
||||
return JSON.stringify({
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
error: formatErrorMessage(error),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import { raceWithTimeoutAndAbort } from "./async.js";
|
||||
import { createFeishuClient, type FeishuClientCredentials } from "./client.js";
|
||||
import type { FeishuProbeResult } from "./types.js";
|
||||
@@ -151,7 +152,7 @@ export async function probeFeishu(
|
||||
{
|
||||
ok: false,
|
||||
appId: creds.appId,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
error: formatErrorMessage(err),
|
||||
},
|
||||
PROBE_ERROR_TTL_MS,
|
||||
);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
|
||||
export function jsonToolResult(data: unknown) {
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }],
|
||||
@@ -10,5 +12,5 @@ export function unknownToolActionResult(action: unknown) {
|
||||
}
|
||||
|
||||
export function toolExecutionErrorResult(error: unknown) {
|
||||
return jsonToolResult({ error: error instanceof Error ? error.message : String(error) });
|
||||
return jsonToolResult({ error: formatErrorMessage(error) });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user