remove unnecessary try/catch
This commit is contained in:
1 parent
da89789a97
commit
0aaeeef113
1 file changed
+7
-11
@@ -13,18 +13,14 @@ const handleError = (error, serviceName, method, status = 500) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fetchMonitorCertificate = async (sslChecker, monitor) => {
|
const fetchMonitorCertificate = async (sslChecker, monitor) => {
|
||||||
try {
|
const monitorUrl = new URL(monitor.url);
|
||||||
const monitorUrl = new URL(monitor.url);
|
const hostname = monitorUrl.hostname;
|
||||||
const hostname = monitorUrl.hostname;
|
const cert = await sslChecker(hostname);
|
||||||
const cert = await sslChecker(hostname);
|
// Throw an error if no cert or if cert.validTo is not present
|
||||||
// Throw an error if no cert or if cert.validTo is not present
|
if (cert?.validTo === null || cert?.validTo === undefined) {
|
||||||
if (cert?.validTo === null || cert?.validTo === undefined) {
|
throw new Error("Certificate not found");
|
||||||
throw new Error("Certificate not found");
|
|
||||||
}
|
|
||||||
return cert;
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
return cert;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { handleValidationError, handleError, fetchMonitorCertificate };
|
export { handleValidationError, handleError, fetchMonitorCertificate };
|
||||||
Reference in new issue
Block a user