eCourt-note/wordaddin/services/errors.ts

11 lines
450 B
TypeScript
Raw Normal View History

2026-10-16 12:07:25 +07:00
/** ข้อความ error ที่อ่านได้สำหรับแสดงใน task pane — ไม่เคย throw (กติกา: ทุก Office.js/API call ต้อง catch) */
export function getErrorMessage(error: unknown, fallback: string): string {
if (error instanceof Error && error.message) {
return error.message;
}
if (typeof error === "string" && error) {
return error;
}
return fallback;
}