Skip to content

Commit

Permalink
add error handle when www.speedtest.net/speedtest-config.php is unava…
Browse files Browse the repository at this point in the history
…ilable
  • Loading branch information
showwin committed Apr 19, 2016
1 parent 79668c2 commit 5e15aba
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ func fetchUserInfo() User {
decoder.DecodeElement(&users, &se)
}
}
if users.Users == nil {
fmt.Println("Warning: Cannot fetch user information. http://www.speedtest.net/speedtest-config.php is temporarily unavailable.")
return User{}
}
return users.Users[0]
}

// Show user location
func (u *User) Show() {
fmt.Println("Testing From IP: " + u.IP + " (" + u.Isp + ") [" + u.Lat + ", " + u.Lon + "]")
if u.IP != "" {
fmt.Println("Testing From IP: " + u.IP + " (" + u.Isp + ") [" + u.Lat + ", " + u.Lon + "]")
}
}

0 comments on commit 5e15aba

Please sign in to comment.