How to extract meaningfull data from an error message when creating an event

9 views
Skip to first unread message

GigaTools

unread,
Jan 31, 2011, 4:38:52 PM1/31/11
to mini_fb
Hey.
I've got a form that posts Facebook Events on a user's behalf. The
form is working fine but i'm trying to improve it and extract some
meaning full data from the response rather than the generic 'Fail'
error im showing now..

I'm using code like this (trimmed for clarity):


begin
@success = @fb.post(@fb.me.id, :type => :events, :params =>
{ etc })
rescue
StandardError
flash[:notice] = 'Facebook rejected your event, please try again.'
redirect_to whatever
end

flash[:notice] = 'Success.'
redirect_to whatever

if @success is successfull, i can extract the URL of the Facebook
event out of that..
If its not, i cant seem to get my hands on anything usefull to display
to the user..

IF i enable
MiniFB.enable_logging

The MiniFB Log gives me a good meaningfull error. but icant seem to
access it.. anyone have any ideas?

EG:
400
ex.http_body={"error":{"type":"OAuthException","message":"(#100) Param
event_info-city must be a valid city"}}

thnks!

Travis Reeder

unread,
Feb 8, 2011, 12:00:18 AM2/8/11
to min...@googlegroups.com
Is that bottom json what Facebook returns?  Maybe they changed that at some point, we currently raise a MiniFB::FaceBookError which includes "error_code" and "error_msg". 

GigaTools

unread,
Feb 8, 2011, 11:58:05 AM2/8/11
to mini_fb
So i should try and grab:

MiniFB::FaceBookError.error_msg

?

thanks

Travis Reeder

unread,
Feb 8, 2011, 12:03:44 PM2/8/11
to min...@googlegroups.com
Did you try ex.message like a normal exception?  

--
You received this message because you are subscribed to the Google Groups "mini_fb" group.
To post to this group, send email to min...@googlegroups.com.
To unsubscribe from this group, send email to mini_fb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mini_fb?hl=en.


GigaTools

unread,
Feb 8, 2011, 2:30:51 PM2/8/11
to mini_fb
No I'm new to Error catching in Rails.
Do you think you could show me how to access the error or this
ex.message in the controller?
that would be awesome if you could.
thanks!

GigaTools

unread,
Feb 8, 2011, 2:36:53 PM2/8/11
to mini_fb
Nevermind.. found it

rescue MiniFB::FaceBookError => exc

exc.message

:-)

Travis Reeder

unread,
Feb 8, 2011, 2:39:47 PM2/8/11
to min...@googlegroups.com
You should probably do some reading so you understand what you are doing: http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html




--
Reply all
Reply to author
Forward
0 new messages