MichaelDeBoey/gatsby-remark-embedder

Handle twitter error for missing or private tweets

Closed this issue ยท 3 comments

Sometimes, a tweet that I have linked to will get turned to private or be otherwise unavailable. This has happened to me a few times when people have made their profiles private or deleted the tweet I linked to:

{
  error: 'Sorry, you are not authorized to see this status.',
  request: '/oembed?url=https://twitter.com/carloscastrodev/status/1156951507125714945&dnt=true&omit_script=true'
}

I feel like there are probably other errors which should be addressed. I'm thinking that we should choose one of two paths forward for this:

  1. log a warning to the console, don't fail the build, but replace the tweet URL with something like: [This tweet is unavailable](link to tweet)
  2. Fail the build with a more helpful error message

I'm leaning to option 2 here. Right now the error message is:

Cannot read property 'replace' of undefined



  TypeError: Cannot read property 'replace' of undefined
  
  - Twitter.js:36 
    [kentcdodds.com]/[gatsby-remark-embedder]/dist/transformers/Twitter.js:36:21
  

Which isn't altogether helpful.

This one's in line with #99

pieh commented

I opened #104 with fix proposal.

I went with option 2 (as in general Gatsby philosophy is that we shouldn't try to workaround content issues and it's better to fail the build, than to have successful build with unexpected content). For gatsby develop case it won't terminate dev server - it will show warning and give chance to adjust link in same session

๐ŸŽ‰ This issue has been resolved in version 1.14.0 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€