From c3a83c7750c15f4146de1cfd80bb7bf2d30b4f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Wed, 3 Apr 2024 00:28:55 +0200 Subject: [PATCH] skip packstate generator error --- cmd/root.go | 11 ++++++----- update/packstate/packstate.go | 1 + web/features.go | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 976059b..4493061 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -157,11 +157,12 @@ var RootCmd = &cobra.Command{ // save state file packState, err := packstate.FromArchive(zipPath) if err != nil { - log.Fatalln(err) - } - err = packState.Save(serverDir) - if err != nil { - log.Fatalln(err) + log.Printf("Unable to generate %s: %s\n", packstate.FileName, err) + } else { + err = packState.Save(serverDir) + if err != nil { + log.Fatalln(err) + } } files.RmEmptyDirs(serverDir) diff --git a/update/packstate/packstate.go b/update/packstate/packstate.go index e14983b..aff437e 100644 --- a/update/packstate/packstate.go +++ b/update/packstate/packstate.go @@ -67,6 +67,7 @@ func FromArchive(path string) (*Schema, error) { version, err := modrinth.Client.VersionFromMrpackFile(path) if err != nil { + // TODO: check for 404 status for custom error return nil, err } project, err := modrinth.Client.GetProject(version.ProjectId) diff --git a/web/features.go b/web/features.go index f78060b..377f3b5 100644 --- a/web/features.go +++ b/web/features.go @@ -37,6 +37,7 @@ func (c *Client) GetModel(url string, respModel interface{}, errModel error, dec }(res.Body) if res.StatusCode < http.StatusOK || res.StatusCode >= http.StatusBadRequest { + // TODO: error struct with more details if errModel == nil || json.NewDecoder(res.Body).Decode(&errModel) != nil { return errors.New("http status " + strconv.Itoa(res.StatusCode)) }