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