1
votes

I have a simple "latest tweets" section on my website. It uses the Twitter Gem and just calls the Twitter API to get the latest 2 tweets and then puts them on the page.

Right now, Twitter's API is down and my website is throwing Twitter::Error::DecodeError. How do I account for times like this and handle it properly?

1

1 Answers

0
votes
begin
  # twitter api call stuff here
rescue Twitter::Error::DecodeError => e
  # stuff you want to make happen then the error is raised i.E.
  Airbrake.notify_or_ignore(e, :parameters => params, :session_data => session)
  # optional raise the error after the catch to handle it elsethere or if you want it to raise
  raise e 
end