From 5757c44e12aef33af796b373f9c49d6c0cb97256 Mon Sep 17 00:00:00 2001 From: Karli Date: Wed, 12 Nov 2025 11:49:39 +0200 Subject: [PATCH] Fix "comment" will never include IDs "doctors that received email: ", improve logging --- app/api/job/send-open-jobs-emails/route.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/api/job/send-open-jobs-emails/route.ts b/app/api/job/send-open-jobs-emails/route.ts index a18d3c6..1efd956 100644 --- a/app/api/job/send-open-jobs-emails/route.ts +++ b/app/api/job/send-open-jobs-emails/route.ts @@ -20,13 +20,14 @@ export const POST = async (request: NextRequest) => { try { const doctors = await sendOpenJobsEmails(); + const doctorIds = doctors?.join(', ') ?? '-'; console.info( - 'Successfully sent out open job notification emails to doctors', + `Successfully sent out open job notification emails to doctorIds: ${doctorIds}`, ); await createNotificationLog({ action: NotificationAction.DOCTOR_NEW_JOBS, status: 'SUCCESS', - comment: `doctors that received email: ${doctors}`, + comment: `doctors that received email: ${doctorIds}`, }); return NextResponse.json( { @@ -35,7 +36,7 @@ export const POST = async (request: NextRequest) => { }, { status: 200 }, ); - } catch (e: any) { + } catch (e) { console.error( 'Error sending out open job notification emails to doctors.', e, @@ -43,7 +44,7 @@ export const POST = async (request: NextRequest) => { await createNotificationLog({ action: NotificationAction.DOCTOR_NEW_JOBS, status: 'FAIL', - comment: e?.message, + comment: e instanceof Error ? e.message : 'Unknown error', }); return NextResponse.json( {