From 0d804e26f22f0356ee169ee4084bcbe982d1e5cb Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Mon, 18 Sep 2023 20:36:20 +0200 Subject: [PATCH] add localAuthority name to send errors --- api.planx.uk/send/bops.ts | 6 +++--- api.planx.uk/send/email.ts | 2 +- api.planx.uk/send/uniform.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api.planx.uk/send/bops.ts b/api.planx.uk/send/bops.ts index 85998b89bb..4565b63a8c 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,7 @@ 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 +150,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}`, }); } }