mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-12 21:27:39 +02:00
twitter: more descriptive errors
This commit is contained in:
@ -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' }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user