You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
My requirements is like these:
Fetch all tweets of some users (from a database), if success then mark a done tag for this user in database, so that this user will no longer be fetched.
When calling the GetUserTweets api, there are 2 different error type:
it may return an Error in the TweetResult struct when the user is suspend or delete its account.
Other errors in tweet result.
For the first case, it's obviously that there's no way to fetch tweets that I need, so it is necessary to mark a done tag for this user in database, after that, this account will never be fetched again.
However in seconde case, there's some other problem when fetching tweets, which means if I call the search function in a few minutes, it may return a success result.
Then I notice that There is no error type when handleing errors in golang.
I must write a string-compare-if sentence to classify those errors.
I'm not sure whether there's another way to handle these.
Here is my code.
funcDigUser(usernamestring, numint, scraper*twitterscraper.Scraper) {
//dig all tweets from a user, num as the limitfullSearchDone:=truelog.Printf("~~ START->%s", username)
results, err:=GetUserTweets(username, num, scraper)
iferr!=nil {
log.Printf("!! ERR WHEN SEARCH->%s", err)
return
}
forresult:=rangeresults {
ifresult.Error!=nil {
ifresult.Error.Error() ==fmt.Sprintf("User '%s' not found", username) {
log.Printf("~! ACCOUNT DELETED->%s", username)
} elseifresult.Error.Error() =="Authorization: User has been suspended. (63)" {
log.Printf("~! ACCOUNT SUSPENDED->%s", username)
} else {
log.Printf("!! ERROR FROM RESULT->%s", result.Error)
fullSearchDone=false// here is why I need to compare the error string
}
continue
}
fullTweetsSaveChan<-&result.Tweet
}
iffullSearchDone {
log.Printf("~! DIG DONE->%s", username)
digUserDone(username)
} else {
log.Printf("~! DIG DONE, PARTIALLY")
}
}
The text was updated successfully, but these errors were encountered:
My requirements is like these:
Fetch all tweets of some users (from a database), if success then mark a done tag for this user in database, so that this user will no longer be fetched.
When calling the
GetUserTweets
api, there are 2 different error type:For the first case, it's obviously that there's no way to fetch tweets that I need, so it is necessary to mark a done tag for this user in database, after that, this account will never be fetched again.
However in seconde case, there's some other problem when fetching tweets, which means if I call the search function in a few minutes, it may return a success result.
Then I notice that There is no error type when handleing errors in golang.
I must write a string-compare-if sentence to classify those errors.
I'm not sure whether there's another way to handle these.
Here is my code.
The text was updated successfully, but these errors were encountered: