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 <udit222001@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
This commit is contained in:
sean-brydon
2024-03-13 17:55:53 +00:00
committed by GitHub
co-authored by Udit Takkar Udit Takkar
parent 4af209fc9d
commit a4bc0793d7
+9 -5
View File
@@ -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;