Improve error messages in parsing of single tweets
This commit is contained in:
parent
56d150d4ae
commit
94e581cc0b
@ -2,6 +2,7 @@ package scraper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"strings"
|
"strings"
|
||||||
@ -10,6 +11,8 @@ import (
|
|||||||
"offline_twitter/terminal_utils"
|
"offline_twitter/terminal_utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ERR_NO_TWEET = errors.New("Empty tweet")
|
||||||
|
|
||||||
type TweetID int64
|
type TweetID int64
|
||||||
|
|
||||||
type CommaSeparatedList []string
|
type CommaSeparatedList []string
|
||||||
@ -124,7 +127,10 @@ func ParseSingleTweet(apiTweet APITweet) (ret Tweet, err error) {
|
|||||||
if apiTweet.TombstoneText == "" { // Skip time parsing for tombstones
|
if apiTweet.TombstoneText == "" { // Skip time parsing for tombstones
|
||||||
ret.PostedAt, err = TimestampFromString(apiTweet.CreatedAt)
|
ret.PostedAt, err = TimestampFromString(apiTweet.CreatedAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Tweet{}, fmt.Errorf("Error parsing time on tweet ID %d:\n %w", ret.ID, err)
|
if ret.ID == 0 {
|
||||||
|
return Tweet{}, fmt.Errorf("unable to parse tweet:\n %w", ERR_NO_TWEET)
|
||||||
|
}
|
||||||
|
return Tweet{}, fmt.Errorf("Error parsing time on tweet ID %d:\n %w", ret.ID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user