From a4bc0793d7f1d6d4dfffdbfa3174f05289268aa9 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Wed, 13 Mar 2024 17:55:53 +0000 Subject: [PATCH] chore: update to see webhook creation error handling to see error in prod (#14071) * chore: update to see erorr in prod * fix: keep try ctach * chore: add logger from lib * chore: improvement --------- Co-authored-by: Udit Takkar Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> --- packages/app-store/paypal/lib/Paypal.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/app-store/paypal/lib/Paypal.ts b/packages/app-store/paypal/lib/Paypal.ts index e430e4d9a8..bcfd9a748b 100644 --- a/packages/app-store/paypal/lib/Paypal.ts +++ b/packages/app-store/paypal/lib/Paypal.ts @@ -3,6 +3,7 @@ import { v4 as uuidv4 } from "uuid"; import z from "zod"; import { IS_PRODUCTION, WEBAPP_URL } from "@calcom/lib/constants"; +import logger from "@calcom/lib/logger"; import prisma from "@calcom/prisma"; class Paypal { @@ -197,12 +198,15 @@ class Paypal { body: JSON.stringify(body), }); - if (response.ok) { - const result = await response.json(); - return result.id as string; + if (!response.ok) { + const message = `${response.statusText}: ${JSON.stringify(await response.json())}`; + throw new Error(message); } - } catch (error) { - console.error(error); + + const result = await response.json(); + return result.id as string; + } catch (e) { + logger.error("Error creating webhook", e); } return false;