Skip to content

Commit

Permalink
fix(electron-updater): Add better error handling for github releases (#…
Browse files Browse the repository at this point in the history
…1114)

Closes #1112
  • Loading branch information
badams authored and develar committed Jan 13, 2017
1 parent 2252964 commit 9dc5bc9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/electron-auto-updater/src/GitHubProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@ export class GitHubProvider implements Provider<VersionInfo> {
}

async getLatestVersion(): Promise<UpdateInfo> {
// do not use API to avoid limit
const basePath = this.getBasePath()
let version = (await request<GithubReleaseInfo>(
{hostname: "github.com", path: `${basePath}/latest`},
null,
null,
"GET",
{"Accept": "application/json"}
)).tag_name
let version = null

try {
version = (version.startsWith("v")) ? version.substring(1) : version
// do not use API to avoid limit
const releaseInfo = (await request<GithubReleaseInfo>(
{hostname: "github.com", path: `${basePath}/latest`},
null,
null,
"GET",
{"Accept": "application/json"}
))

version = (releaseInfo.tag_name.startsWith("v")) ? releaseInfo.tag_name.substring(1) : releaseInfo.tag_name
}
catch (e) {
throw new Error(`Cannot parse determine latest version from github "${version}": ${e.stack || e.message}`)
throw new Error(`Unable to find latest version on github, please ensure a production release exists. \n ${e.stack || e.message}`)
}

let result: UpdateInfo | null = null
Expand Down

0 comments on commit 9dc5bc9

Please sign in to comment.