I am new to Ruby On Rails & developing a web application with Facebook connectivity implemented in it. I am using omniauth & fb_graph gem to authenticate user & to get user’s information.
While posting user’s post on our site to his facebook wall, I am facing issues in two different use cases:
-
If user updates duplicate status message in my application I am getting following exception
FbGraph::Unauthorized (OAuthException :: (#506) Duplicate status message): -
If suppose user changes his facebook password then the user’s access token which I get from omniauth becomes invalid & I get following exception
FbGraph::Unauthorized (OAuthException :: Error validating access token: Session does not match current stored session. This may be because the user changed the password since the time the session was created or Facebook has changed the session for security reasons.):
I am currently doing this but I want to perform two different actions for two differnt exceptions. If status message is duplicate, it should handle the first excepion.
In 2nd exception it should ask to reconnect the facebook account to my application so that I can get the new access token.
Please help.
Thank you.
According to the documentation, the exception should have
code,type, andmessageattributes. You can tell determine which action to take based on one of those attributes (all exceptions havemessage, so that is generally useful, but you may find thatcodeortypeis better in this particular instance.