Spaces:
Paused
Paused
Deploy Bot commited on
Commit ·
4fa4be7
1
Parent(s): 4802130
Feat: Add granular error reporting to Checkout Flow
Browse files- src/scenes/user/checkout.js +14 -2
src/scenes/user/checkout.js
CHANGED
|
@@ -108,8 +108,20 @@ async function finishOrder(ctx) {
|
|
| 108 |
return ctx.scene.leave();
|
| 109 |
|
| 110 |
} catch (err) {
|
| 111 |
-
console.error(err);
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
return ctx.scene.leave();
|
| 114 |
}
|
| 115 |
}
|
|
|
|
| 108 |
return ctx.scene.leave();
|
| 109 |
|
| 110 |
} catch (err) {
|
| 111 |
+
console.error("ORDER_CREATION_ERROR:", err);
|
| 112 |
+
|
| 113 |
+
// Handle Duplicate Key Error (Self-Healing Attempt)
|
| 114 |
+
if (err.code === 11000) {
|
| 115 |
+
ctx.reply("⚠️ Tizimda qisqa nosozlik (ID Duplicate). Iltimos, qayta 'Buyurtma berish' tugmasini bosing.");
|
| 116 |
+
// Ideally we retry, but for now asking user is safer than infinite loop
|
| 117 |
+
} else {
|
| 118 |
+
const errorMsg = (err.message || "").substring(0, 50);
|
| 119 |
+
ctx.reply(`❌ Tizim xatoligi yuz berdi: ${errorMsg}\n\nIltimos, adminga xabar bering.`);
|
| 120 |
+
// Notify admin about the crash
|
| 121 |
+
for (const adminId of config.ADMIN_IDS) {
|
| 122 |
+
ctx.telegram.sendMessage(adminId, `🚨 **CRITICAL CHECKOUT ERROR**:\nUser: ${ctx.from.id}\nError: ${err.message}`, { parse_mode: 'Markdown' }).catch(e => console.error(e));
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
return ctx.scene.leave();
|
| 126 |
}
|
| 127 |
}
|