From 5ae792bdd31bdf8ebe6deaf4f8cb9edd6db21fc4 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Fri, 15 Jul 2022 13:18:59 +0700 Subject: [PATCH] Catch API errors --- src/providers/Daemon.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/providers/Daemon.ts b/src/providers/Daemon.ts index 16dcbd8..5b35daf 100644 --- a/src/providers/Daemon.ts +++ b/src/providers/Daemon.ts @@ -71,8 +71,13 @@ class Deamon { } } - const IPv4 = await this.getCurrentIPv4(); - const IPv6 = await this.getCurrentIPv6(); + let IPv4, IPv6; + try { + IPv4 = await this.getCurrentIPv4(); + IPv6 = await this.getCurrentIPv6(); + } catch(err) { + Logger.error(`Unable to fetch ip address: ${err}`); + } IPv4 && Logger.info(`Current IPv4 address: ${IPv4}`); IPv6 && Logger.info(`Current IPv6 address: ${IPv6}`);