Skip to content

Commit 56b91b1

Browse files
author
Maggie Chen
committed
wrap resolver in try catch
1 parent c39ab26 commit 56b91b1

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

backend/typescript/graphql/resolvers/applicantRecordResolvers.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ApplicantRecordService from "../../services/implementations/applicantRecordService";
22
import IApplicantRecordService from "../../services/interfaces/applicantRecordService";
33
import { ApplicantRecordDTO } from "../../types";
4+
import { getErrorMessage } from "../../utilities/errorUtils";
45

56
const applicantRecordService: IApplicantRecordService =
67
new ApplicantRecordService();
@@ -14,12 +15,16 @@ const applicantRecordResolvers = {
1415
flagValue,
1516
}: { applicantRecordId: string; flagValue: boolean },
1617
): Promise<ApplicantRecordDTO> => {
17-
const applicantRecord =
18-
await applicantRecordService.setApplicantRecordFlag(
19-
applicantRecordId,
20-
flagValue,
21-
);
22-
return applicantRecord;
18+
try {
19+
const applicantRecord =
20+
await applicantRecordService.setApplicantRecordFlag(
21+
applicantRecordId,
22+
flagValue,
23+
);
24+
return applicantRecord;
25+
} catch (error: unknown) {
26+
throw new Error(getErrorMessage(error));
27+
}
2328
},
2429
},
2530
};

0 commit comments

Comments
 (0)