Add logging if downloading an image from unsplash fails
This commit is contained in:
parent
54b18b3c59
commit
42ddee8d6f
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue