From 364356c9bd06983ba9d1f5f5da30b59407ba4b8d Mon Sep 17 00:00:00 2001 From: Luka Gulin Date: Thu, 27 Apr 2023 21:16:08 +0200 Subject: [PATCH] Fix error handling --- src/certificates/apiSign.ts | 20 ++++++++------------ src/certificates/index.ts | 14 ++++++++------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/certificates/apiSign.ts b/src/certificates/apiSign.ts index 2c64a2a..0bcee9c 100644 --- a/src/certificates/apiSign.ts +++ b/src/certificates/apiSign.ts @@ -4,18 +4,14 @@ import axios from "axios"; import shell from "../utils/shell"; async function getEthSignature(timestamp: number): Promise<[string, string]> { - try { - const response = await axios.post( - process.env.DAPPMANAGER_SIGN, - timestamp.toString(), - { - headers: { "Content-Type": "text/plain" }, - } - ); - return [response.data.signature, response.data.address]; - } catch (e) { - console.warn(e); - } + const response = await axios.post( + process.env.DAPPMANAGER_SIGN, + timestamp.toString(), + { + headers: { "Content-Type": "text/plain" }, + } + ); + return [response.data.signature, response.data.address]; } async function executeAPISign( diff --git a/src/certificates/index.ts b/src/certificates/index.ts index 514674a..fb00f42 100644 --- a/src/certificates/index.ts +++ b/src/certificates/index.ts @@ -10,11 +10,7 @@ import { export async function ensureValidCert(createIfNotExists = false) { if (await shouldRenew(createIfNotExists)) { - try { - await signCert(); - } catch (e) { - console.log(e); - } + await signCert(); } else { console.log("Certificate valid or not necessary, skip signing"); } @@ -37,7 +33,13 @@ export default async function initCertificateProvider() { } console.log("Setting cronjob for cert updates"); - setInterval(ensureValidCert, config.certCheckInterval); + setInterval(async () => { + try { + await ensureValidCert(); + } catch (e) { + console.warn(e); + } + }, config.certCheckInterval); } async function signCert() {