From 5e9dd765354ee8fd8f8e736ce3acb1b651c1d8c5 Mon Sep 17 00:00:00 2001 From: Minh Nguyen <64875104+MinhxNguyen7@users.noreply.github.com> Date: Mon, 3 Jun 2024 01:03:21 -0700 Subject: [PATCH] feat: meeting dates insertion in response --- src/lib/db/databaseUtils.server.ts | 8 +++++++- src/routes/api/create/+server.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/db/databaseUtils.server.ts b/src/lib/db/databaseUtils.server.ts index f84ed1ed..0e833356 100644 --- a/src/lib/db/databaseUtils.server.ts +++ b/src/lib/db/databaseUtils.server.ts @@ -132,7 +132,13 @@ export const insertMeetingDates = async (dates: Date[], meeting_id: string) => { return { meeting_id, date: startOfDay }; }); - await db.insert(meetingDates).values(dbMeetingDates); + try { + await db.insert(meetingDates).values(dbMeetingDates); + } + catch (err) { + console.error("Error inserting meeting dates=", dbMeetingDates); + throw err; + } }; export const getExistingMeetingDates = async (meetingId: string) => { diff --git a/src/routes/api/create/+server.ts b/src/routes/api/create/+server.ts index 25ed7e0f..8978d918 100644 --- a/src/routes/api/create/+server.ts +++ b/src/routes/api/create/+server.ts @@ -43,6 +43,6 @@ export async function POST({ request }) { } catch (err) { console.error("Error creating meeting:", err, meeting, sortedDates); // TODO: This is unsafe - throw error(500, `${err.stack}\nmeeting schema: ${JSON.stringify(meeting)}`); + throw error(500, `Error creating meeting: ${err.message}`); } }