// A readable message from any thrown value. Tauri plugin calls and rejected // promises often throw a plain string or an object, so `(e as Error).message` // is undefined and surfaces as "Error: undefined". This always returns // something legible. export function errorMessage(e: unknown): string { if (typeof e === 'string') return e; if (e instanceof Error && e.message) return e.message; if (e && typeof e === 'object' && 'message' in e) { const m = (e as { message?: unknown }).message; if (typeof m === 'string' && m) return m; } try { const s = JSON.stringify(e); if (s && s !== '{}') return s; } catch { // fall through } return String(e); }