Add try/catch to
This commit is contained in:
1 parent
a27cadc94f
commit
54fca685c0
1 file changed
+10
-4
@@ -39,9 +39,15 @@ const getStatusPageByUrl = async (url) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const urlIsUnique = async (url) => {
|
const urlIsUnique = async (url) => {
|
||||||
const statusPage = await StatusPage.find({ url });
|
try {
|
||||||
if (statusPage.length > 0) return false;
|
const statusPage = await StatusPage.find({ url });
|
||||||
return true;
|
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 };
|
||||||
Reference in new issue
Block a user