diff --git a/app/server/cli/commands/import-config.ts b/app/server/cli/commands/import-config.ts index b3607f44..b336f0e5 100644 --- a/app/server/cli/commands/import-config.ts +++ b/app/server/cli/commands/import-config.ts @@ -1,8 +1,7 @@ import { Command } from "commander"; import path from "node:path"; import fs from "node:fs/promises"; - -const toError = (e: unknown): Error => (e instanceof Error ? e : new Error(String(e))); +import { toError } from "../../utils/errors"; type Output = ReturnType; diff --git a/app/server/modules/lifecycle/config-import.ts b/app/server/modules/lifecycle/config-import.ts index 76822b17..08e18073 100644 --- a/app/server/modules/lifecycle/config-import.ts +++ b/app/server/modules/lifecycle/config-import.ts @@ -10,6 +10,7 @@ import { notificationDestinationsTable, } from "../../db/schema"; import { logger } from "../../utils/logger"; +import { toError } from "../../utils/errors"; import { volumeService } from "../volumes/volume.service"; import type { NotificationConfig } from "~/schemas/notifications"; import type { RepositoryConfig } from "~/schemas/restic"; @@ -17,8 +18,6 @@ import type { BackendConfig } from "~/schemas/volumes"; const isRecord = (value: unknown): value is Record => typeof value === "object" && value !== null; -const toError = (e: unknown): Error => (e instanceof Error ? e : new Error(String(e))); - const asStringArray = (value: unknown): string[] => { if (!Array.isArray(value)) return []; return value.filter((item): item is string => typeof item === "string"); diff --git a/app/server/utils/errors.ts b/app/server/utils/errors.ts index 22379a36..3ff14939 100644 --- a/app/server/utils/errors.ts +++ b/app/server/utils/errors.ts @@ -18,6 +18,8 @@ export const toMessage = (err: unknown): string => { return sanitizeSensitiveData(message); }; +export const toError = (e: unknown): Error => (e instanceof Error ? e : new Error(String(e))); + const resticErrorCodes: Record = { 1: "Command failed: An error occurred while executing the command.", 2: "Go runtime error: A runtime error occurred in the Go program.",