mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 03:20:23 +00:00
refactor: dedupe probe error formatting
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { formatErrorMessage } from "../../infra/errors.js";
|
||||
|
||||
type BatchOutputErrorLike = {
|
||||
error?: { message?: string };
|
||||
response?: {
|
||||
@@ -26,6 +28,6 @@ export function extractBatchErrorMessage(lines: BatchOutputErrorLike[]): string
|
||||
}
|
||||
|
||||
export function formatUnavailableBatchError(err: unknown): string | undefined {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const message = formatErrorMessage(err);
|
||||
return message ? `error file unavailable: ${message}` : undefined;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { DatabaseSync } from "node:sqlite";
|
||||
import { formatErrorMessage } from "../../infra/errors.js";
|
||||
|
||||
export function ensureMemoryIndexSchema(params: {
|
||||
db: DatabaseSync;
|
||||
@@ -74,7 +75,7 @@ export function ensureMemoryIndexSchema(params: {
|
||||
);
|
||||
ftsAvailable = true;
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const message = formatErrorMessage(err);
|
||||
ftsAvailable = false;
|
||||
ftsError = message;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { formatErrorMessage } from "../../infra/errors.js";
|
||||
import { createSubsystemLogger } from "../../logging/subsystem.js";
|
||||
|
||||
const log = createSubsystemLogger("memory");
|
||||
@@ -42,7 +43,7 @@ export function parseQmdQueryJson(stdout: string, stderr: string): QmdQueryResul
|
||||
}
|
||||
throw new Error("qmd query JSON response was not an array");
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const message = formatErrorMessage(err);
|
||||
log.warn(`qmd query returned invalid JSON: ${message}`);
|
||||
throw new Error(`qmd query returned invalid JSON: ${message}`, { cause: err });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { DatabaseSync } from "node:sqlite";
|
||||
import { formatErrorMessage } from "../../infra/errors.js";
|
||||
|
||||
export async function loadSqliteVecExtension(params: {
|
||||
db: DatabaseSync;
|
||||
@@ -18,7 +19,7 @@ export async function loadSqliteVecExtension(params: {
|
||||
|
||||
return { ok: true, extensionPath };
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const message = formatErrorMessage(err);
|
||||
return { ok: false, error: message };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createRequire } from "node:module";
|
||||
import { formatErrorMessage } from "../../infra/errors.js";
|
||||
import { installProcessWarningFilter } from "../../infra/warning-filter.js";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
@@ -8,7 +9,7 @@ export function requireNodeSqlite(): typeof import("node:sqlite") {
|
||||
try {
|
||||
return require("node:sqlite") as typeof import("node:sqlite");
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const message = formatErrorMessage(err);
|
||||
// Node distributions can ship without the experimental builtin SQLite module.
|
||||
// Surface an actionable error instead of the generic "unknown builtin module".
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user