Improve GetDetails and Search
We now use the right log object with prefix and return an error on GetDetails only if the error is Fatal
This commit is contained in:
parent
8a07623668
commit
91bf3f8cdb
@ -11,6 +11,7 @@ import (
|
||||
"git.quimbo.fr/odwrtw/canape/backend/models"
|
||||
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||
"github.com/odwrtw/errors"
|
||||
"github.com/odwrtw/papi"
|
||||
polochon "github.com/odwrtw/polochon/lib"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -97,9 +98,11 @@ func (m *Movie) GetDetails(env *web.Env, detailers []polochon.Detailer) error {
|
||||
m.Detailers = detailers
|
||||
|
||||
// GetDetail
|
||||
err := polochon.GetDetails(m.Movie, env.Log)
|
||||
err := polochon.GetDetails(m.Movie, log)
|
||||
if err != nil {
|
||||
return err
|
||||
if errors.IsFatal(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug("got details from detailers")
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"git.quimbo.fr/odwrtw/canape/backend/models"
|
||||
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||
"github.com/odwrtw/errors"
|
||||
"github.com/odwrtw/papi"
|
||||
polochon "github.com/odwrtw/polochon/lib"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -211,9 +212,11 @@ func (e *Episode) GetEpisodeDetails(env *web.Env, detailers []polochon.Detailer)
|
||||
e.ShowEpisode.Detailers = detailers
|
||||
|
||||
// Get the details
|
||||
err := polochon.GetDetails(e.ShowEpisode, env.Log)
|
||||
err := polochon.GetDetails(e.ShowEpisode, log)
|
||||
if err != nil {
|
||||
return err
|
||||
if errors.IsFatal(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug("got details from detailers")
|
||||
|
@ -128,11 +128,13 @@ func SearchShow(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
||||
searchers := env.Config.Show.Searchers
|
||||
// Iterate on all the searchers to search for the show
|
||||
for _, searcher := range searchers {
|
||||
result, err := searcher.SearchShow(search, env.Log)
|
||||
log := env.Log.WithField("searcher", searcher.Name())
|
||||
result, err := searcher.SearchShow(search, log)
|
||||
if err != nil {
|
||||
env.Log.Errorf("error while searching show : %s", err)
|
||||
log.Errorf("error while searching show : %s", err)
|
||||
continue
|
||||
}
|
||||
log.Debug("found show")
|
||||
// Add the results to the list of results
|
||||
shows = append(shows, result...)
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"git.quimbo.fr/odwrtw/canape/backend/models"
|
||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||
"github.com/odwrtw/errors"
|
||||
"github.com/odwrtw/papi"
|
||||
polochon "github.com/odwrtw/polochon/lib"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -95,9 +96,11 @@ func (s *Show) GetDetails(env *web.Env, detailers []polochon.Detailer) error {
|
||||
s.Detailers = detailers
|
||||
|
||||
// Get the details
|
||||
err := polochon.GetDetails(s.Show, env.Log)
|
||||
err := polochon.GetDetails(s.Show, log)
|
||||
if err != nil {
|
||||
return err
|
||||
if errors.IsFatal(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("got details from detailers")
|
||||
|
1
go.mod
1
go.mod
@ -14,6 +14,7 @@ require (
|
||||
github.com/lib/pq v1.1.1
|
||||
github.com/mattn/go-sqlite3 v1.10.0 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/odwrtw/errors v0.0.0-20170604160533-c747b9d17833
|
||||
github.com/odwrtw/papi v0.0.0-20190511132159-936937ad8b6a
|
||||
github.com/odwrtw/polochon v0.0.0-20200131104911-522892bdd053
|
||||
github.com/phyber/negroni-gzip v0.0.0-20180113114010-ef6356a5d029
|
||||
|
Loading…
x
Reference in New Issue
Block a user