From 1912d7932dec13570bcee79b4956747516b06d74 Mon Sep 17 00:00:00 2001 From: G Date: Tue, 28 May 2024 10:14:52 +0000 Subject: [PATCH] updating the name property of known error for specific handling --- src/utils/requests/orangePayment.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils/requests/orangePayment.ts b/src/utils/requests/orangePayment.ts index e7bcce2..1f6825f 100644 --- a/src/utils/requests/orangePayment.ts +++ b/src/utils/requests/orangePayment.ts @@ -64,7 +64,15 @@ export const getTransactionStatus = async (orderId: string) => { log.http("getTransactionStatus |", JSON.stringify(response, null, 2)); if (response.status === "INITIATED") { log.warn("Payment is still in progress, throwing error for mutation to catch"); - throw new Error("Payment is still in progress"); + const error = new Error("Payment is still in progress"); + error.name = "PaymentInProgress"; + throw error; + } + if (response.status === "FAILED") { + log.warn("Payment failed, throwing error for mutation to catch"); + const error = new Error("Payment failed"); + error.name = "PaymentFailed"; + throw error; } log.http("getTransactionStatus |", JSON.stringify(response, null, 2)); return response; -- libgit2 0.27.1