Skip to content

Commit

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

0 comments on commit a6d2e9f

Please sign in to comment.