Diagnose image worker failures and normalize Facebook uploads
This commit is contained in:
@@ -20,7 +20,19 @@ export async function runAutomation(body: Record<string, unknown>, options: { wa
|
||||
throw new UserFacingError("Worker กำลังทำงานอื่น ลองสั่งสร้างใหม่เมื่อพร้อม");
|
||||
}
|
||||
if (response.status === 429) throw new UserFacingError("โควตา AI ของบัญชีที่ใช้สร้างเนื้อหาเต็มชั่วคราว ลองใหม่อีกครั้งภายหลัง");
|
||||
if (!response.ok) throw new Error(`Worker status ${response.status}`);
|
||||
if (!response.ok) {
|
||||
const failure = await response.json().catch(() => ({}));
|
||||
const hints: Record<string, string> = {
|
||||
DESKTOP_UNAVAILABLE: "เครื่องสร้างรูปไม่มีหน้าจอ Chrome ที่ใช้งานได้ — ปลดล็อก desktop session ของ worker แล้วลองใหม่",
|
||||
LOGIN_REQUIRED: "บัญชี ChatGPT บนเครื่อง worker ต้องเข้าสู่ระบบใหม่",
|
||||
CHAT_UNAVAILABLE: "หน้า ChatGPT บนเครื่อง worker ไม่พร้อมใช้งาน — ตรวจหน้าเว็บหรือ extension",
|
||||
IMAGE_EXPORT_FAILED: "สร้างรูปแล้ว แต่ดึงไฟล์จาก ChatGPT ไม่สำเร็จ — ตรวจรูปใน Chrome ก่อนลองใหม่",
|
||||
};
|
||||
const code = typeof failure.code === "string" ? failure.code : "UNKNOWN";
|
||||
console.error("[ai:automation] worker response", { status: response.status, code });
|
||||
if (hints[code]) throw new UserFacingError(hints[code]);
|
||||
throw new Error(`Worker status ${response.status} (${code})`);
|
||||
}
|
||||
return await response.json();
|
||||
}
|
||||
throw new Error("Worker did not accept the job");
|
||||
|
||||
Reference in New Issue
Block a user