2011-12-12 4 views
0

Facebook에 게시중인 Rails 애플리케이션이 있습니다. 나는 같은 메시지를 두 번 게시하는 오류를 막기 위해 구조를했다. 내 응용 프로그램에 사용자에게 알리고 계속 진행하도록하고 싶지만이 오류를 구할 수는 없습니다.Ruby on Rails Facebook Graph API OAuth 오류 # 506 중복 상태 메시지

begin 
    current_user.facebook.feed!(:message => 'THIS IS A TEST PLEASE IGNORE::Hello, Facebook!') 
rescue FbGraph::Unauthorized 
    flash[:alert] = "Already Posted" 
end 
redirect_to show(@track) 

이 코드로 얻을 오류는 다음과 같습니다 :

OAuthException : (# 506) 중복 상태 메시지

답변

1

왜 구출하는

내 코드입니다 OAuthException 오류가 발생하면 FbGraph::Unauthorized에서 오류가 발생합니까?

begin 
    current_user.facebook.feed!(:message => 'THIS IS A TEST PLEASE IGNORE::Hello, Facebook!') 
rescue OAuthException 
    flash[:alert] = "Already Posted" 
end 
redirect_to show(@track) 
+0

나는 그것이 OAuthException 또는 예외 :: OAuthException 작업을 가져올 수 없습니다. 그들은 알려지지 않은 예외를 말했지만, 나는 대신 모든 예외를 구했어. – richsoni

0

시도 :

begin 
    current_user.facebook.feed!(:message => 'THIS IS A TEST PLEASE IGNORE::Hello, Facebook!') 
rescue => e 
    if(e.fb_error_type == "OAuthException" 
    flash[:alert] = "Already Posted" 
    end 
end