Have nicer 404 errors for covers
This commit is contained in:
@@ -97,6 +97,7 @@ func (a *appData) buildRouter() http.Handler {
|
||||
|
||||
if err != nil {
|
||||
narco.Error(ctx, w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
rc, ext, err := a.cover.GetCover(AlbumID(ID))
|
||||
@@ -104,10 +105,16 @@ func (a *appData) buildRouter() http.Handler {
|
||||
defer closeOrPanic(rc, "Album cover "+name)
|
||||
}
|
||||
if err != nil {
|
||||
if _, ok := err.(ErrorNotRegistered); ok == true {
|
||||
narco.Error(ctx, w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
narco.Error(ctx, w, err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if ext != requestedExt {
|
||||
narco.Error(ctx, w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
io.Copy(w, rc)
|
||||
|
||||
Reference in New Issue
Block a user