error catching

This commit is contained in:
Vincent Cloutier 2022-11-25 14:48:10 -05:00
parent 0d8db06855
commit 3a0ba5bcd5

View file

@ -134,25 +134,34 @@ namespace BirdsiteLive.Twitter
foreach (JsonElement tweet in timelineElement.GetProperty("entries").EnumerateArray()) foreach (JsonElement tweet in timelineElement.GetProperty("entries").EnumerateArray())
{ {
var extractedTweet = new ExtractedTweet try
{ {
Id = Int64.Parse(tweet.GetProperty("sortIndex").GetString()),
InReplyToStatusId = null, var extractedTweet = new ExtractedTweet
InReplyToAccount = null, {
MessageContent = tweet.GetProperty("content").GetProperty("item_contenet") Id = Int64.Parse(tweet.GetProperty("sortIndex").GetString()),
.GetProperty("tweet_results").GetProperty("result").GetProperty("legacy") InReplyToStatusId = null,
.GetProperty("full_text").GetString(), InReplyToAccount = null,
CreatedAt = tweet.GetProperty("content").GetProperty("item_contenet") MessageContent = tweet.GetProperty("content").GetProperty("item_contenet")
.GetProperty("tweet_results").GetProperty("result").GetProperty("legacy") .GetProperty("tweet_results").GetProperty("result").GetProperty("legacy")
.GetProperty("created_at").GetDateTime(), .GetProperty("full_text").GetString(),
IsReply = false, CreatedAt = tweet.GetProperty("content").GetProperty("item_contenet")
IsThread = false, .GetProperty("tweet_results").GetProperty("result").GetProperty("legacy")
IsRetweet = false, .GetProperty("created_at").GetDateTime(),
Media = null, IsReply = false,
RetweetUrl = "https://t.co/123", IsThread = false,
OriginalAuthor = null, IsRetweet = false,
}; Media = null,
extractedTweets.Append(extractedTweet); RetweetUrl = "https://t.co/123",
OriginalAuthor = null,
};
extractedTweets.Append(extractedTweet);
}
catch (Exception e)
{
_logger.LogError("Tried getting timeline from user " + username + ", but got error: \n" + e.Message + e.StackTrace + e.Source);
}
} }
} }