Skip to content

Commit

Permalink
chore: Improve email failure logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Jan 25, 2025
1 parent 5607aff commit f14e9cc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api.planx.uk/modules/sendEmail/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,20 @@ export const confirmationEmailController: ConfirmationEmail = async (
return res.json(response);
}
} catch (error) {
emailErrorHandler(next, error, template);
emailErrorHandler(next, error, template, sessionId);
}
};

const emailErrorHandler = (
next: NextFunction,
error: unknown,
template: string,
sessionId: string,
) =>
next(
new ServerError({
status: error instanceof ServerError ? error.status : undefined,
message: `Failed to send "${template}" email. ${
message: `Failed to send "${template}" email for session ${sessionId}. ${
(error as Error).message
}`,
}),
Expand Down

0 comments on commit f14e9cc

Please sign in to comment.