From 26426514ddf0fd8a134664f7667c338ddc1460c9 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Tue, 19 Sep 2023 08:48:46 +0100 Subject: [PATCH] fix: include local authority name on submission errors (#2221) --- api.planx.uk/send/bops.ts | 8 +++++--- api.planx.uk/send/email.ts | 2 +- api.planx.uk/send/uniform.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api.planx.uk/send/bops.ts b/api.planx.uk/send/bops.ts index 85998b89bb..5ce11c974a 100644 --- a/api.planx.uk/send/bops.ts +++ b/api.planx.uk/send/bops.ts @@ -134,7 +134,7 @@ const sendToBOPS = async (req: Request, res: Response, next: NextFunction) => { .catch((error) => { if (error.response) { throw new Error( - `Sending to BOPS failed:\n${JSON.stringify( + `Sending to BOPS failed (${localAuthority}):\n${JSON.stringify( error.response.data, null, 2, @@ -142,7 +142,9 @@ const sendToBOPS = async (req: Request, res: Response, next: NextFunction) => { ); } else { // re-throw other errors - throw new Error(`Sending to BOPS failed:\n${error}`); + throw new Error( + `Sending to BOPS failed (${localAuthority}):\n${error}`, + ); } }); res.send(bopsResponse); @@ -150,7 +152,7 @@ const sendToBOPS = async (req: Request, res: Response, next: NextFunction) => { next( new ServerError({ status: 500, - message: "Sending to BOPS failed", + message: `Sending to BOPS failed (${localAuthority})`, cause: err, }), ); diff --git a/api.planx.uk/send/email.ts b/api.planx.uk/send/email.ts index ee48599305..40ee5a360b 100644 --- a/api.planx.uk/send/email.ts +++ b/api.planx.uk/send/email.ts @@ -75,7 +75,7 @@ export async function sendToEmail( if (response?.message !== "Success") { return next({ status: 500, - message: `Failed to send "Submit" email: ${response?.message}`, + message: `Failed to send "Submit" email (${localAuthority}): ${response?.message}`, }); } // Mark session as submitted so that reminder and expiry emails are not triggered diff --git a/api.planx.uk/send/uniform.ts b/api.planx.uk/send/uniform.ts index 56c3281d24..df4a74eca9 100644 --- a/api.planx.uk/send/uniform.ts +++ b/api.planx.uk/send/uniform.ts @@ -159,7 +159,7 @@ export async function sendToUniform( } catch (error) { return next({ error, - message: `Failed to send to Uniform. ${error}`, + message: `Failed to send to Uniform (${localAuthority}): ${error}`, }); } }