From 528da39e66447e0fc8eab2e993516c12a6585bf6 Mon Sep 17 00:00:00 2001 From: spiral Date: Wed, 14 Sep 2022 20:56:52 +0000 Subject: [PATCH] fix(dashboard): correctly fail in createEmbed matching `nil != nil` doesn't work, no clue what this code was supposed to do --- dashboard/main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dashboard/main.go b/dashboard/main.go index 7396b021..311bb7cb 100644 --- a/dashboard/main.go +++ b/dashboard/main.go @@ -84,7 +84,7 @@ func notFoundHandler(rw http.ResponseWriter, r *http.Request) { // explanation for createEmbed: // we don't care about errors, we just want to return a HTML page as soon as possible -// `panic(nil)` is caught by upstream, which then returns the raw HTML page +// `panic(1)` is caught by upstream, which then returns the raw HTML page func createEmbed(rw http.ResponseWriter, r *http.Request) { entityType := chi.URLParam(r, "type") @@ -100,22 +100,22 @@ func createEmbed(rw http.ResponseWriter, r *http.Request) { case "g": path = "/groups/" + id default: - panic(nil) + panic(1) } res, err := http.Get(baseURL + path) if err != nil { - panic(nil) + panic(1) } if res.StatusCode != 200 { - panic(nil) + panic(1) } var data entity body, _ := io.ReadAll(res.Body) err = json.Unmarshal(body, &data) if err != nil { - panic(nil) + panic(1) } text := fmt.Sprintf(`%s`, baseURL, path, "\n") @@ -136,7 +136,7 @@ func createEmbed(rw http.ResponseWriter, r *http.Request) { html, err := fs.ReadFile("dist/index.html") if err != nil { - panic(nil) + panic(1) } html = []byte(strings.Replace(string(html), ``, text+versionJS, 1))