Add ErrNotFound
This commit is contained in:
parent
d4fbec39a6
commit
53324e663a
@ -91,6 +91,8 @@ type Info struct {
|
|||||||
Result []Fileinfo `json:"result"`
|
Result []Fileinfo `json:"result"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ErrNotFound = errors.New("404 not found")
|
||||||
|
|
||||||
func getJson(query string, target interface{}) (err error) {
|
func getJson(query string, target interface{}) (err error) {
|
||||||
flog := log.With().Str("url", query).Logger()
|
flog := log.With().Str("url", query).Logger()
|
||||||
|
|
||||||
@ -111,8 +113,14 @@ func getJson(query string, target interface{}) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
flog.Debug().Msgf("%s", resp.Status)
|
flog.Debug().Msgf("%s", resp.Status)
|
||||||
|
|
||||||
|
if resp.StatusCode == 404 {
|
||||||
|
err = ErrNotFound
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if resp.StatusCode < 500 {
|
if resp.StatusCode < 500 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user