Skip to content

Commit 6c2f203

Browse files
authored
chore: improve error messages when validating icons (#111)
Signed-off-by: Ivan Pedrazas <[email protected]>
1 parent 8e4a637 commit 6c2f203

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cmd/validate/main.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,27 @@ func isIconValid(name string) error {
146146
return nil
147147
}
148148
defer resp.Body.Close()
149+
149150
if resp.StatusCode != 200 {
150-
return fmt.Errorf("icon is not valid. It must be a valid image")
151+
fmt.Printf("🛑 Icon could not be fetched, status code: %d, url: %s\n", resp.StatusCode, server.About.Icon)
152+
return nil
151153
}
152154
if resp.ContentLength > 2*1024*1024 {
153-
return fmt.Errorf("icon is too large. It must be less than 2MB")
155+
fmt.Println("🛑 Icon is too large. It must be less than 2MB")
156+
return nil
154157
}
155158
img, format, err := image.DecodeConfig(resp.Body)
156159
if err != nil {
157160
return err
158161
}
159162
if format != "png" {
160-
return fmt.Errorf("icon is not a png. It must be a png")
163+
fmt.Println("🛑 Icon is not a png. It must be a png")
164+
return nil
161165
}
162166

163167
if img.Width > 512 || img.Height > 512 {
164-
return fmt.Errorf("image is too large. It must be less than 512x512")
168+
fmt.Println("🛑 Icon is too large. It must be less than 512x512")
169+
return nil
165170
}
166171

167172
fmt.Println("✅ Icon is valid")

0 commit comments

Comments
 (0)