Skip to content

Commit 656ffbc

Browse files
authored
chore: fix error in validating icon. Shows proper message (#97)
Signed-off-by: Ivan Pedrazas <[email protected]>
1 parent facfe5d commit 656ffbc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cmd/validate/main.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,27 +135,29 @@ func isIconValid(name string) error {
135135
return err
136136
}
137137

138-
if server.Image == "" {
139-
return fmt.Errorf("image is not valid. It must be a valid image")
138+
if server.About.Icon == "" {
139+
fmt.Println("🛑 No icon found")
140+
return nil
140141
}
141142
// fetch the image and check the size
142143
resp, err := http.Get(server.About.Icon)
143144
if err != nil {
144-
return err
145+
fmt.Println("🛑 Icon could not be fetched")
146+
return nil
145147
}
146148
defer resp.Body.Close()
147149
if resp.StatusCode != 200 {
148-
return fmt.Errorf("image is not valid. It must be a valid image")
150+
return fmt.Errorf("icon is not valid. It must be a valid image")
149151
}
150152
if resp.ContentLength > 2*1024*1024 {
151-
return fmt.Errorf("image is too large. It must be less than 2MB")
153+
return fmt.Errorf("icon is too large. It must be less than 2MB")
152154
}
153155
img, format, err := image.DecodeConfig(resp.Body)
154156
if err != nil {
155157
return err
156158
}
157159
if format != "png" {
158-
return fmt.Errorf("image is not a png. It must be a png")
160+
return fmt.Errorf("icon is not a png. It must be a png")
159161
}
160162

161163
if img.Width > 512 || img.Height > 512 {

0 commit comments

Comments
 (0)