11 lines
450 B
TypeScript
11 lines
450 B
TypeScript
|
|
/** ข้อความ 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;
|
||
|
|
}
|