From 4f6b5e98570130dbdddcdea152b8c2cf0dde0b07 Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 8 Nov 2023 18:55:39 +0900 Subject: [PATCH] fix: handle invalid url outside try-catch statement --- cli/src/utils.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cli/src/utils.ts b/cli/src/utils.ts index e934113a4..00933e9d3 100644 --- a/cli/src/utils.ts +++ b/cli/src/utils.ts @@ -60,11 +60,12 @@ export async function isOraklNetworkApiHealthy() { } export async function isOraklFetcherHealthy(url: string) { - try { - if (!(await isValidUrl(url))) { - throw new Error('Invalid URL') - } + if (!(await isValidUrl(url))) { + console.error('Invalid URL') + return false + } + try { const response = await axios.get(url) if (response.status === 200) { return true @@ -73,13 +74,9 @@ export async function isOraklFetcherHealthy(url: string) { return false } } catch (error) { - if (error.message === 'Invalid URL') { - console.error(error.message) - } else { console.error( `An error occurred while checking the Orakl Network Fetcher [${url}]: ${error.message}` ) - } return false } }