mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 10:41:23 +00:00
refactor: dedupe provider bootstrap error formatting
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { defineBundledChannelEntry } from "openclaw/plugin-sdk/channel-entry-contract";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import { registerMatrixCliMetadata } from "./cli-metadata.js";
|
||||
|
||||
export default defineBundledChannelEntry({
|
||||
@@ -23,12 +24,12 @@ export default defineBundledChannelEntry({
|
||||
void import("./plugin-entry.handlers.runtime.js")
|
||||
.then(({ ensureMatrixCryptoRuntime }) =>
|
||||
ensureMatrixCryptoRuntime({ log: api.logger.info }).catch((err: unknown) => {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const message = formatErrorMessage(err);
|
||||
api.logger.warn?.(`matrix: crypto runtime bootstrap failed: ${message}`);
|
||||
}),
|
||||
)
|
||||
.catch((err: unknown) => {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const message = formatErrorMessage(err);
|
||||
api.logger.warn?.(`matrix: failed loading crypto bootstrap runtime: ${message}`);
|
||||
});
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import fs from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import type { RuntimeEnv } from "../runtime-api.js";
|
||||
|
||||
const REQUIRED_MATRIX_PACKAGES = [
|
||||
@@ -137,7 +138,7 @@ function defaultResolveFn(id: string): string {
|
||||
}
|
||||
|
||||
function isMissingMatrixCryptoRuntimeError(error: unknown): boolean {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const message = formatErrorMessage(error);
|
||||
return (
|
||||
message.includes("@matrix-org/matrix-sdk-crypto-nodejs-") ||
|
||||
message.includes("matrix-sdk-crypto-nodejs") ||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import type { OpenClawConfig, OpenClawPluginApi } from "../api.js";
|
||||
import { applyMemoryWikiMutation, normalizeMemoryWikiMutationInput } from "./apply.js";
|
||||
import { compileMemoryWikiVault } from "./compile.js";
|
||||
@@ -78,7 +79,7 @@ function readEnumParam<T extends string>(
|
||||
}
|
||||
|
||||
function respondError(respond: GatewayRespond, error: unknown) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const message = formatErrorMessage(error);
|
||||
respond(false, undefined, { code: "internal_error", message });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ProviderAuthContext } from "openclaw/plugin-sdk/core";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import {
|
||||
azLoginDeviceCode,
|
||||
azLoginDeviceCodeWithOptions,
|
||||
@@ -422,7 +423,7 @@ export async function loginWithTenantFallback(
|
||||
await azLoginDeviceCode();
|
||||
return { account: getLoggedInAccount() };
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const message = formatErrorMessage(error);
|
||||
const isAzureTenantError =
|
||||
/AADSTS\d+/i.test(message) ||
|
||||
/no subscriptions found/i.test(message) ||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ProviderPrepareRuntimeAuthContext } from "openclaw/plugin-sdk/core";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import { ensureAuthProfileStore } from "openclaw/plugin-sdk/provider-auth";
|
||||
import { getAccessTokenResultAsync } from "./cli.js";
|
||||
import {
|
||||
@@ -95,7 +96,7 @@ export async function prepareFoundryRuntimeAuth(ctx: ProviderPrepareRuntimeAuthC
|
||||
...(baseUrl ? { baseUrl } : {}),
|
||||
};
|
||||
} catch (err) {
|
||||
const details = err instanceof Error ? err.message : String(err);
|
||||
const details = formatErrorMessage(err);
|
||||
throw new Error(`Failed to refresh Azure Entra ID token via az CLI: ${details}`, {
|
||||
cause: err,
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import {
|
||||
definePluginEntry,
|
||||
type ProviderAuthContext,
|
||||
@@ -169,7 +170,7 @@ function createOAuthHandler(region: MiniMaxRegion) {
|
||||
],
|
||||
});
|
||||
} catch (err) {
|
||||
const errorMsg = err instanceof Error ? err.message : String(err);
|
||||
const errorMsg = formatErrorMessage(err);
|
||||
progress.stop(`MiniMax OAuth failed: ${errorMsg}`);
|
||||
await ctx.prompter.note(
|
||||
"If OAuth fails, verify your MiniMax account has portal access and try again.",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import { finalizeEvent, SimplePool, type Event } from "nostr-tools";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import { type NostrProfile, NostrProfileSchema } from "./config-schema.js";
|
||||
|
||||
// ============================================================================
|
||||
@@ -186,7 +187,7 @@ export async function publishProfileEvent(
|
||||
|
||||
successes.push(relay);
|
||||
} catch (err) {
|
||||
const errorMessage = err instanceof Error ? err.message : String(err);
|
||||
const errorMessage = formatErrorMessage(err);
|
||||
failures.push({ relay, error: errorMessage });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import type {
|
||||
ProviderAuthContext,
|
||||
ProviderResolveDynamicModelContext,
|
||||
@@ -182,7 +183,7 @@ async function refreshOpenAICodexOAuthCredential(cred: OAuthCredential) {
|
||||
displayName: cred.displayName,
|
||||
};
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const message = formatErrorMessage(error);
|
||||
if (
|
||||
/extract\s+accountid\s+from\s+token/i.test(message) &&
|
||||
typeof cred.access === "string" &&
|
||||
|
||||
@@ -4,6 +4,7 @@ import { request } from "node:https";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { pipeline } from "node:stream/promises";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import { runPluginCommandWithTimeout } from "openclaw/plugin-sdk/run-command";
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
|
||||
import { CONFIG_DIR, extractArchive, resolveBrewExecutable } from "openclaw/plugin-sdk/setup-tools";
|
||||
@@ -258,7 +259,7 @@ async function installSignalCliFromRelease(runtime: RuntimeEnv): Promise<SignalI
|
||||
try {
|
||||
await extractSignalCliArchive(archivePath, installRoot, 60_000);
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const message = formatErrorMessage(err);
|
||||
return {
|
||||
ok: false,
|
||||
error: `Failed to extract ${asset.name}: ${message}`,
|
||||
|
||||
Reference in New Issue
Block a user