Skip to content

Commit

Permalink
throw proper error if any of the requests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Aug 3, 2024
1 parent 1c1feaa commit 4802562
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function download (
log.info(`Downloading Edgedriver from ${downloadUrl}`)
const res = await fetch(downloadUrl)

if (!res.body) {
if (!res.body || !res.ok || res.status !== 200) {
throw new Error(`Failed to download binary (statusCode ${res.status})`)
}

Expand Down Expand Up @@ -151,7 +151,12 @@ export async function fetchVersion (edgeVersion: string) {
if (edgeVersion.match(MATCH_VERSION)) {
const [major] = edgeVersion.match(MATCH_VERSION)
const url = format(LATEST_RELEASE_URL, major.toString().toUpperCase(), platform.toUpperCase())
log.info(`Fetching latest version from ${url}`)
const res = await fetch(url)
if (!res.ok || res.status !== 200) {
throw new Error(`Couldn't detect version for ${edgeVersion}`)
}

return (await res.text()).replace(/\0/g, '').slice(2).trim()
}

Expand Down

0 comments on commit 4802562

Please sign in to comment.