Fix "comment" will never include IDs "doctors that received email: ", improve logging
This commit is contained in:
@@ -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(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user