From a6d2e9ff896d604a8aa49962bbd7743a777b6aa7 Mon Sep 17 00:00:00 2001 From: Minh Nguyen <64875104+MinhxNguyen7@users.noreply.github.com> Date: Mon, 3 Jun 2024 01:15:17 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20split=20error=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/db/databaseUtils.server.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/db/databaseUtils.server.ts b/src/lib/db/databaseUtils.server.ts index cc9c002..9275b80 100644 --- a/src/lib/db/databaseUtils.server.ts +++ b/src/lib/db/databaseUtils.server.ts @@ -114,15 +114,17 @@ export const getExistingGuest = async (username: string, meeting: MeetingSelectS * @returns The id of the inserted meeting. */ export const insertMeeting = async (meeting: MeetingInsertSchema, meetingDates: Date[]) => { - try { - const [dbMeeting] = await db.insert(meetings).values(meeting).returning(); - await insertMeetingDates(meetingDates, dbMeeting.id); + let dbMeeting: MeetingSelectSchema; - return dbMeeting.id; + try { + [dbMeeting] = await db.insert(meetings).values(meeting).returning(); } catch (err) { console.error("Error inserting meeting=", meeting); throw Error(`Error inserting meeting=${meeting}`); } + + await insertMeetingDates(meetingDates, dbMeeting.id); + return dbMeeting.id; }; export const getExistingMeeting = async (meetingId: string) => {