Skip to content

Commit

Permalink
Fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
3alpha committed Apr 27, 2023
1 parent c34a133 commit 364356c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
20 changes: 8 additions & 12 deletions src/certificates/apiSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 8 additions & 6 deletions src/certificates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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() {
Expand Down

0 comments on commit 364356c

Please sign in to comment.