0

I want to catch a Twitter::Error that happens in a view partial and still load the page. Put another way, I don't want a Twitter::Error to stop the page from loading. I just want that partial to not be loaded.

https://gist.github.com/scottmagdalein/903cd168ea4171365d51

Scott Magdalein
  • 361
  • 1
  • 3
  • 13

1 Answers1

0

You can rescue from errors to allow what you need:

def my_method
  begin
    # do some things
  rescue Twitter::Error
    flash[:notice] = 'oh dear!'
  end

  # any other view code
end

You catch the error, set a message, then continue to your view.

Matt
  • 13,948
  • 6
  • 44
  • 68
  • It doesn't really matter what goes there, could be nothing at all, just making the point that the code will continue after the rescue, not halt. – Matt Jun 12 '13 at 18:44