diff --git a/extensions/tlon/src/monitor/discovery.ts b/extensions/tlon/src/monitor/discovery.ts index b6b73114fa6..b13e6cee5ec 100644 --- a/extensions/tlon/src/monitor/discovery.ts +++ b/extensions/tlon/src/monitor/discovery.ts @@ -1,10 +1,6 @@ import type { RuntimeEnv } from "../../api.js"; import type { Foreigns } from "../urbit/foreigns.js"; -import { asRecord, formatChangesDate } from "./utils.js"; - -function formatErrorMessage(error: unknown): string { - return error instanceof Error ? error.message : String(error); -} +import { asRecord, formatChangesDate, formatErrorMessage } from "./utils.js"; export async function fetchGroupChanges( api: { scry: (path: string) => Promise }, diff --git a/extensions/tlon/src/monitor/history.ts b/extensions/tlon/src/monitor/history.ts index cf926b24199..99902394300 100644 --- a/extensions/tlon/src/monitor/history.ts +++ b/extensions/tlon/src/monitor/history.ts @@ -1,9 +1,5 @@ import type { RuntimeEnv } from "../../api.js"; -import { asRecord, extractMessageText } from "./utils.js"; - -function formatErrorMessage(error: unknown): string { - return error instanceof Error ? error.message : String(error); -} +import { asRecord, extractMessageText, formatErrorMessage } from "./utils.js"; /** * Format a number as @ud (with dots every 3 digits from the right) diff --git a/extensions/tlon/src/monitor/index.ts b/extensions/tlon/src/monitor/index.ts index b5f7bcf4e8b..6139c46be4a 100644 --- a/extensions/tlon/src/monitor/index.ts +++ b/extensions/tlon/src/monitor/index.ts @@ -28,7 +28,7 @@ import { mergeUniqueStrings, shouldMigrateTlonSetting, } from "./settings-helpers.js"; -import { asRecord } from "./utils.js"; +import { asRecord, formatErrorMessage } from "./utils.js"; import { extractMessageText, formatModelName, @@ -56,10 +56,6 @@ function readNumber(record: Record | null, key: string): number return typeof value === "number" && Number.isFinite(value) ? value : undefined; } -function formatErrorMessage(error: unknown): string { - return error instanceof Error ? error.message : String(error); -} - export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise { const core = getTlonRuntime(); const cfg = core.config.loadConfig(); diff --git a/extensions/tlon/src/monitor/utils.ts b/extensions/tlon/src/monitor/utils.ts index d8d2553a948..bce4b430253 100644 --- a/extensions/tlon/src/monitor/utils.ts +++ b/extensions/tlon/src/monitor/utils.ts @@ -185,6 +185,10 @@ export function asRecord(value: unknown): Record | null { return value && typeof value === "object" ? (value as Record) : null; } +export function formatErrorMessage(error: unknown): string { + return error instanceof Error ? error.message : String(error); +} + function readString(record: Record, key: string): string | undefined { const value = record[key]; return typeof value === "string" ? value : undefined;