extra error checking
This commit is contained in:
parent
9c68067fc3
commit
80adf6214e
@ -51,7 +51,11 @@ func getNewestPost(subreddit string) (post, error) {
|
|||||||
if len(resp.Data.Children) < 1 {
|
if len(resp.Data.Children) < 1 {
|
||||||
return post{}, errors.New("bad data from reddit")
|
return post{}, errors.New("bad data from reddit")
|
||||||
}
|
}
|
||||||
numS := re.FindStringSubmatch(resp.Data.Children[0].Data.Title)[0]
|
reSearch := re.FindStringSubmatch(resp.Data.Children[0].Data.Title)
|
||||||
|
if len(reSearch) == 0 {
|
||||||
|
return post{}, fmt.Errorf("Something strange in data from reddit")
|
||||||
|
}
|
||||||
|
numS := reSearch[0]
|
||||||
num, err := strconv.Atoi(numS)
|
num, err := strconv.Atoi(numS)
|
||||||
if err != nil || numS == "" {
|
if err != nil || numS == "" {
|
||||||
num = -1
|
num = -1
|
||||||
|
Loading…
Reference in New Issue
Block a user