Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Log email and s3 submission failures to airbrake #4210

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions api.planx.uk/modules/send/email/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ServerError } from "../../../errors/serverError.js";
import { sendEmail } from "../../../lib/notify/index.js";
import type { EmailSubmissionNotifyConfig } from "../../../types.js";
import { markSessionAsSubmitted } from "../../saveAndReturn/service/utils.js";
Expand Down Expand Up @@ -77,11 +78,12 @@ export const sendToEmail: SendIntegrationController = async (
govuk_notify_template: "Submit",
});
} catch (error) {
return next({
error,
message: `Failed to send "Submit" email (${localAuthority}): ${
(error as Error).message
}`,
});
return next(
new ServerError({
message: `Failed to send "Submit" email (${localAuthority}): ${
(error as Error).message
}`,
}),
);
}
};
14 changes: 8 additions & 6 deletions api.planx.uk/modules/send/s3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { markSessionAsSubmitted } from "../../saveAndReturn/service/utils.js";
import { isApplicationTypeSupported } from "../utils/helpers.js";
import type { SendIntegrationController } from "../types.js";
import { convertObjectToMulterJSONFile } from "../../file/service/utils.js";
import { ServerError } from "../../../errors/serverError.js";

interface CreateS3Application {
insertS3Application: {
Expand Down Expand Up @@ -127,12 +128,13 @@ const sendToS3: SendIntegrationController = async (_req, res, next) => {
auditEntryId,
});
} catch (error) {
return next({
error,
message: `Failed to upload submission to S3 (${localAuthority}): ${
(error as Error).message
}`,
});
return next(
new ServerError({
message: `Failed to upload submission to S3 (${localAuthority}): ${
(error as Error).message
}`,
}),
);
}
};

Expand Down
Loading