diff --git a/pkg/modules/background/unsplash/unsplash.go b/pkg/modules/background/unsplash/unsplash.go index b2ddd1f40d..d036601057 100644 --- a/pkg/modules/background/unsplash/unsplash.go +++ b/pkg/modules/background/unsplash/unsplash.go @@ -17,6 +17,7 @@ package unsplash import ( + "bytes" "code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/files" "code.vikunja.io/api/pkg/log" @@ -200,6 +201,13 @@ func (p *Provider) Set(image *background.Image, list *models.List, auth web.Auth } defer resp.Body.Close() + if resp.StatusCode > 399 { + b := bytes.Buffer{} + _, _ = b.ReadFrom(resp.Body) + log.Errorf("Error getting unsplash photo %s: Request failed with status %d, message was %s", photo.ID, resp.StatusCode, b.String()) + return + } + log.Debugf("Downloaded Unsplash Photo %s", image.ID) // Save it as a file in vikunja