From f05d50572bc01df6d3ae051f44fb417f9ea2ab3d Mon Sep 17 00:00:00 2001 From: Alexejhero <32238504+Alexejhero@users.noreply.github.com> Date: Tue, 11 Jun 2024 01:10:34 +0200 Subject: [PATCH] add logging to prepurchase failing --- ebs/src/modules/transactions.ts | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/ebs/src/modules/transactions.ts b/ebs/src/modules/transactions.ts index d5dd67c..2dacea4 100644 --- a/ebs/src/modules/transactions.ts +++ b/ebs/src/modules/transactions.ts @@ -39,7 +39,41 @@ app.post("/public/prepurchase", async (req, res) => { // TODO: Verify parameters // TODO: text input moderation - const token = await registerPrepurchase(idCart); + let token: string; + try { + token = await registerPrepurchase(idCart); + } catch (e: any) { + logToDiscord({ + transactionToken: null, + userIdInsecure: idCart.userId, + important: true, + fields: [ + { + header: "Failed to register prepurchase", + content: { + cart: idCart, + error: e, + } + }, + ] + }).then(); + res.status(500).send("Failed to register prepurchase"); + return; + } + + logToDiscord({ + transactionToken: token, + userIdInsecure: idCart.userId, + important: false, + fields: [ + { + header: "Created prepurchase", + content: { + cart: idCart, + } + } + ] + }).then(); res.status(200).send(token); });