How can I rescue from an OAuth::Unauthorized exception as raised from OmniAuth in a Ruby on Rails application?
Obviously this:
rescue_from OAuth::Unauthorized, :with => :unauthorized
won't work as that only catches exception thrown inside Rails and this exception is thrown somewhere else in the rack chain.
In this application the administrators (and not us, the developers) configure the credentials for twitter and facebook, so having the wrong ones is something that can happen and indeed does happen. I'd like to show a better message that "Something went wrong" when that happens.
Update: I also asked on the omniauth google group, so far there are no answers, but if you are reading this question you might want to check it out.