Add try/catch to

This commit is contained in:
Alex Holliday
2024-11-11 14:25:34 +08:00
parent a27cadc94f
commit 54fca685c0

View File

@@ -39,9 +39,15 @@ const getStatusPageByUrl = async (url) => {
};
const urlIsUnique = async (url) => {
const statusPage = await StatusPage.find({ url });
if (statusPage.length > 0) return false;
return true;
try {
const statusPage = await StatusPage.find({ url });
if (statusPage.length > 0) return false;
return true;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "urlIsUnique";
throw error;
}
};
export { createStatusPage, getStatusPageByUrl };
export { createStatusPage, getStatusPageByUrl, urlIsUnique };