Improve upgrade error messages

This commit is contained in:
Michael Ploujnikov 2015-11-23 19:37:42 -05:00
parent bd4a14519c
commit 9edf8233f7
2 changed files with 6 additions and 5 deletions

View File

@ -30,7 +30,8 @@ type Asset struct {
var ( var (
ErrVersionUpToDate = errors.New("current version is up to date") ErrVersionUpToDate = errors.New("current version is up to date")
ErrVersionUnknown = errors.New("couldn't fetch release information") ErrNoReleaseDownload = errors.New("couldn't find a release to download")
ErrNoVersionToSelect = errors.New("no version to select")
ErrUpgradeUnsupported = errors.New("upgrade unsupported") ErrUpgradeUnsupported = errors.New("upgrade unsupported")
ErrUpgradeInProgress = errors.New("upgrade already in progress") ErrUpgradeInProgress = errors.New("upgrade already in progress")
upgradeUnlocked = make(chan bool, 1) upgradeUnlocked = make(chan bool, 1)

View File

@ -49,7 +49,7 @@ var insecureHTTP = &http.Client{
// FetchLatestReleases returns the latest releases, including prereleases or // FetchLatestReleases returns the latest releases, including prereleases or
// not depending on the argument // not depending on the argument
func FetchLatestReleases(releasesURL, version string) ([]Release) { func FetchLatestReleases(releasesURL, version string) []Release {
resp, err := insecureHTTP.Get(releasesURL) resp, err := insecureHTTP.Get(releasesURL)
if err != nil { if err != nil {
l.Infoln("Couldn't fetch release information:", err) l.Infoln("Couldn't fetch release information:", err)
@ -86,7 +86,7 @@ func LatestRelease(releasesURL, version string) (Release, error) {
func SelectLatestRelease(version string, rels []Release) (Release, error) { func SelectLatestRelease(version string, rels []Release) (Release, error) {
if len(rels) == 0 { if len(rels) == 0 {
return Release{}, ErrVersionUnknown return Release{}, ErrNoVersionToSelect
} }
sort.Sort(SortByRelease(rels)) sort.Sort(SortByRelease(rels))
@ -108,7 +108,7 @@ func SelectLatestRelease(version string, rels []Release) (Release, error) {
} }
} }
} }
return Release{}, ErrVersionUnknown return Release{}, ErrNoReleaseDownload
} }
// Upgrade to the given release, saving the previous binary with a ".old" extension. // Upgrade to the given release, saving the previous binary with a ".old" extension.
@ -124,7 +124,7 @@ func upgradeTo(binary string, rel Release) error {
} }
} }
return ErrVersionUnknown return ErrNoReleaseDownload
} }
// Upgrade to the given release, saving the previous binary with a ".old" extension. // Upgrade to the given release, saving the previous binary with a ".old" extension.