remove unnecessary try/catch

This commit is contained in:
Alex Holliday
2025-01-19 09:56:28 -08:00
parent da89789a97
commit 0aaeeef113

View File

@@ -13,18 +13,14 @@ const handleError = (error, serviceName, method, status = 500) => {
};
const fetchMonitorCertificate = async (sslChecker, monitor) => {
try {
const monitorUrl = new URL(monitor.url);
const hostname = monitorUrl.hostname;
const cert = await sslChecker(hostname);
// Throw an error if no cert or if cert.validTo is not present
if (cert?.validTo === null || cert?.validTo === undefined) {
throw new Error("Certificate not found");
}
return cert;
} catch (error) {
throw error;
const monitorUrl = new URL(monitor.url);
const hostname = monitorUrl.hostname;
const cert = await sslChecker(hostname);
// Throw an error if no cert or if cert.validTo is not present
if (cert?.validTo === null || cert?.validTo === undefined) {
throw new Error("Certificate not found");
}
return cert;
};
export { handleValidationError, handleError, fetchMonitorCertificate };