From 4b296ec70b9aee6aea43b4d7c56d45c4f283ce1e Mon Sep 17 00:00:00 2001 From: Stephen Horvath Date: Tue, 13 Feb 2024 14:39:10 +1000 Subject: [PATCH] Make error messages in update information less vague. --- internal/helpers/updateinformation.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/helpers/updateinformation.go b/internal/helpers/updateinformation.go index fee974c5..ac47d348 100644 --- a/internal/helpers/updateinformation.go +++ b/internal/helpers/updateinformation.go @@ -58,12 +58,12 @@ func NewUpdateInformationFromString(updateinformation string) (UpdateInformation ui.transportmechanism = parts[0] if ui.transportmechanism == "zsync" { if len(parts) < 2 { - return ui, errors.New("Too short") + return ui, errors.New("Update information isn't valid") } ui.fileurl = parts[1] } else if ui.transportmechanism == "gh-releases-zsync" { if len(parts) < 5 { - return ui, errors.New("Too short") + return ui, errors.New("Update information isn't valid") } ui.username = parts[1] ui.repository = parts[2] @@ -71,14 +71,14 @@ func NewUpdateInformationFromString(updateinformation string) (UpdateInformation ui.filename = parts[4] } else if ui.transportmechanism == "bintray-zsync" { if len(parts) < 5 { - return ui, errors.New("Too short") + return ui, errors.New("Update information isn't valid") } ui.username = parts[1] ui.repository = parts[2] ui.packagename = parts[3] ui.filename = parts[4] // a.k.a. "zsync path" } else { - return ui, errors.New("This transport mechanism is not yet implemented") + return ui, errors.New("The transport mechanism in update information is not yet implemented") } return ui, nil } @@ -89,7 +89,7 @@ func NewUpdateInformationFromString(updateinformation string) (UpdateInformation func ValidateUpdateInformation(updateinformation string) error { parts := strings.Split(updateinformation, "|") if len(parts) < 2 { - return errors.New("Too short") + return errors.New("Update information isn't valid") } // Check for allowed transport mechanisms, // https://github.com/AppImage/AppImageSpec/blob/master/draft.md#update-information @@ -101,7 +101,7 @@ func ValidateUpdateInformation(updateinformation string) error { } } if detectedTm == "" { - return errors.New("Invalid transport mechanism") + return errors.New("Invalid transport mechanism in update information") } // Currently updateinformation needs to end in "zsync" for all transport mechanisms, @@ -109,13 +109,13 @@ func ValidateUpdateInformation(updateinformation string) error { // Note that it is allowable to have something like "some.zsync?foo=bar", which is why we parse it as an URL u, err := url.Parse(parts[len(parts)-1]) if err != nil { - return errors.New("Cannot parse URL") + return errors.New("Cannot parse URL in update information") } if detectedTm == "zsync" && u.Scheme == "" { // FIXME: This apparently never triggers, why? - return errors.New("Scheme is missing, zsync needs e.,g,. http:// or https://") + return errors.New("Scheme is missing in update information, zsync needs e.,g,. http:// or https://") } if strings.HasSuffix(u.Path, ".zsync") == false { - return errors.New(updateinformation + " does not end in .zsync") + return errors.New("Update information '" + updateinformation + "' does not end in .zsync") } return nil