Skip to content

Commit

Permalink
feat: ✨ more error printing
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhxNguyen7 committed Jun 3, 2024
1 parent 5e9dd76 commit e52a0ea
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/lib/db/databaseUtils.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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}`);
}
};

Expand Down

0 comments on commit e52a0ea

Please sign in to comment.