twitter: more descriptive errors

This commit is contained in:
wukko
2024-02-02 23:12:05 +06:00
parent a0df70110d
commit 6de230f642
3 changed files with 19 additions and 4 deletions

View File

@ -86,7 +86,18 @@ export default async function({ id, index, toGif }) {
tweet = await tweet.json();
// {"data":{"tweetResult":{"result":{"__typename":"TweetUnavailable","reason":"Protected"}}}}
if (tweet?.data?.tweetResult?.result?.__typename !== "Tweet") {
const tweetTypename = tweet?.data?.tweetResult?.result?.__typename;
if (tweetTypename === "TweetUnavailable") {
const reason = tweet?.data?.tweetResult?.result?.reason;
switch(reason) {
case "Protected":
return { error: 'ErrorTweetProtected' }
case "NsfwLoggedOut":
return { error: 'ErrorTweetNSFW' }
}
}
if (tweetTypename !== "Tweet") {
return { error: 'ErrorTweetUnavailable' }
}