Skip to content

Commit

Permalink
fix: include local authority name on submission errors (#2221)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Sep 19, 2023
1 parent 1ec5003 commit 2642651
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions api.planx.uk/send/bops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,25 @@ 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,
)}`,
);
} 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);
} catch (err) {
next(
new ServerError({
status: 500,
message: "Sending to BOPS failed",
message: `Sending to BOPS failed (${localAuthority})`,
cause: err,
}),
);
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/send/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/send/uniform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
});
}
}
Expand Down

0 comments on commit 2642651

Please sign in to comment.