Skip to content

Commit

Permalink
Detailed err message on wrong request url (#903)
Browse files Browse the repository at this point in the history
* fix: add if statement to check if given url is valid

* fix: remove empty linebreaks

* fix: detailed descriptions

* fix: rollback which is out of task scope

* fix: handle invalid url outside try-catch statement

* fix: format document
  • Loading branch information
nick-bisonai authored Nov 8, 2023
1 parent f6a2464 commit 4e3f86f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,23 @@ export async function isOraklNetworkApiHealthy() {
}

export async function isOraklFetcherHealthy(url: string) {
if (!(await isValidUrl(url))) {
console.error('Invalid URL')
return false
}

try {
return 200 === (await axios.get(url))?.status
} catch (e) {
console.error(`Orakl Network Fetcher [${url}] is down`)
const response = await axios.get(url)
if (response.status === 200) {
return true
} else {
console.error(`Orakl Network Fetcher [${url}] is down. HTTP Status: ${response.status}`)
return false
}
} catch (error) {
console.error(
`An error occurred while checking the Orakl Network Fetcher [${url}]: ${error.message}`
)
return false
}
}
Expand Down

0 comments on commit 4e3f86f

Please sign in to comment.