mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-15 03:30:39 +03:00
Better error handling when cover art cannot be loaded
This commit is contained in:
parent
c6ed0d5377
commit
8a1110044c
@ -2,6 +2,7 @@ package engine
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"image"
|
||||
_ "image/gif"
|
||||
"image/jpeg"
|
||||
@ -100,5 +101,9 @@ func readFromTag(path string) (io.Reader, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return bytes.NewReader(m.Picture().Data), nil
|
||||
picture := m.Picture()
|
||||
if picture == nil {
|
||||
return nil, errors.New("error extracting art from file " + path)
|
||||
}
|
||||
return bytes.NewReader(picture.Data), nil
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ func (c *MediaRetrievalController) GetCoverArt(w http.ResponseWriter, r *http.Re
|
||||
|
||||
switch {
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, err.Error(), "id", id)
|
||||
log.Error(r, "Couldn't find coverArt", "id", id, err)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Cover not found")
|
||||
case err != nil:
|
||||
log.Error(r, err)
|
||||
log.Error(r, "Error retrieving coverArt", "id", id, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user