From 42ddee8d6f0a8cb97f3e9334c4a5d0d800c2b739 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 29 May 2020 22:11:49 +0200 Subject: [PATCH] Add logging if downloading an image from unsplash fails --- pkg/modules/background/unsplash/unsplash.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/modules/background/unsplash/unsplash.go b/pkg/modules/background/unsplash/unsplash.go index b2ddd1f40da..d0366010575 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