/** * Extract a human-readable message from an unknown error value. * * Use this in every `catch (e: unknown)` block instead of accessing * `e?.message` directly — TypeScript's `unknown` type prevents property * access without a type guard. */ export function getErrorMessage(e: unknown, fallback = "An unexpected error occurred"): string { return e instanceof Error ? e.message : fallback; }