Updating batchfb

16 views
Skip to first unread message

Jeff Schnitzer

unread,
Apr 29, 2014, 2:06:20 AM4/29/14
to bat...@googlegroups.com
BatchFB has been neglected for a while, so I modernized it:

 * Repo converted to git
 * Fixed the longstanding bug regarding nulls in the next/previous when paging.
 * Added the code and subcode field to errors.

I'd like to open up a discussion of the error handling strategy. When I wrote BatchFB I needed to be able to handle certain cases (permission errors and page migration errors) which were not well-structured in FB's response. Since then, Facebook has added better structure (code/subcode) but I no longer need this behavior, and no longer have a testbed app to verify the error codes.

The error codes are underdocumented in standard Facebook style.

Do I:

 * Remove the extra exception types and just throw the CodedFacebookException whenever we get a coded response?

 * Implore someone here to verify what are and aren't useful exception types?

 * Leave the existing code in place, which inspects the message strings for codes?

Note that if only ever catch FacebookException or CodedFacebookException, you won't have to care about any of this. The question is, what's most useful to you all? While I still actively use BatchFB, my use of FB's API is not so extensive anymore so I don't see the edge cases.

Once we resolve this question, I'll make another dot release of BatchFB.

Jeff
Message has been deleted

omer.h...@gmail.com

unread,
Jan 13, 2015, 6:17:54 AM1/13/15
to bat...@googlegroups.com, je...@infohazard.org
Sorry, I pressed Post to early... posting again:
Hi Jeff,
I know that your post is from April, but I just encountered some issues with the error handling part in batchfb. It is probably not relevant now, but I am OK with keeping the current exception mechanism in place.
I do think that some information is missing from the exception. The exceptions includes the code, subcode and message. But in the error reply from facebook there are few other fields. The error_user_title and error_user_msg info can help a lot to quickly understand what is the exception cause.

In addition, I found a bug in the error handling code:
- in ErrorDetectingWrapper.java under impl, in function checkForStandardGraphError, line 108, I saw the following:

================================================================
// Documented here: https://developers.facebook.com/docs/graph-api/using-graph-api
if (code == 10 || (code >= 200 || code <= 299))
    throw new PermissionException(msg, type, code, subcode);
================================================================
As written in the facebook documentation errors 200-299 are permission issues. But the code should be:
================================================================
// Documented here: https://developers.facebook.com/docs/graph-api/using-graph-api
if (code == 10 || (code >= 200 && code <= 299))
    throw new PermissionException(msg, type, code, subcode);
================================================================

In the original code, if code = 100, we will still throw a PermissionException. the code == 10 will be false, but the (code >= 200 || code <= 299) will be true as code <= 299 is true.

Thanks
Omer

Jeff Schnitzer

unread,
Jan 13, 2015, 3:00:54 PM1/13/15
to bat...@googlegroups.com
I have fixed the || vs && bug (doh!) and added the new fields to the exception. Try it out; if it works the way you like, I'll make a release.

Thanks!

Jeff

--
You received this message because you are subscribed to the Google Groups "BatchFB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to batchfb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

omer.h...@gmail.com

unread,
Jan 14, 2015, 4:24:10 AM1/14/15
to bat...@googlegroups.com, je...@infohazard.org
Hi Jeff,
Works like a charm. I will only add getters for userTitle and userMsg in ErrorFacebookException
Thanks
Omer

Jeff Schnitzer

unread,
Jan 14, 2015, 4:53:19 AM1/14/15
to bat...@googlegroups.com
Doh! I forgot this project hasn't been lombok-ized.

Fixed. Also, I pushed 2.1.6 to maven central.

Jeff

Vidosh Sahu

unread,
Jun 6, 2015, 3:02:08 PM6/6/15
to bat...@googlegroups.com, je...@infohazard.org
Hi Jeff,

First, I would like to appreciate your effort to build this really cool library. I am using 2.1.6 version and I think this is the latest one. When I am trying to get post or comments information using id  everything is working fine except that the createdTime and updatedTime are null. Can you please help me out here.

Thanks  

Jeff Schnitzer

unread,
Jun 7, 2015, 2:08:55 PM6/7/15
to bat...@googlegroups.com
You mean, createdTime and updatedTime are null in the response? Have you looked at the JSON that comes back from FB and checked to make sure those fields are present if you hit the graph api directly?

Jeff

Vidosh Sahu

unread,
Jun 8, 2015, 1:46:21 AM6/8/15
to bat...@googlegroups.com, je...@infohazard.org
Yes, the json response has both these fields but during de-serialization get lost.

Thanks,
Vidosh 

Jeff Schnitzer

unread,
Jun 8, 2015, 3:15:55 AM6/8/15
to bat...@googlegroups.com
BatchFB code is not involved in the mapping of JSON to objects. That's all done by Jackson, which is highly unlikely to have any bugs this obvious. This is most likely an issue with the class you are trying to map onto.

If you can post a small example that demonstrates the problem, I might be able to help. Jackson has quite a lot of complex mapping abilities; maybe there's some impedance mismatch between what Facebook and Jackson consider dates (ie, a type issue).

Jeff

Vidosh Sahu

unread,
Jun 8, 2015, 3:33:31 AM6/8/15
to bat...@googlegroups.com, je...@infohazard.org
Here is the code snippet -

.......
.......

Batcher batcher = new FacebookBatcher(accessToken, Version.VERSION_2_3.getUrlElement());
Later<Post> laterPost = batcher.graph(postId, Post.class);
Post post = laterPost.get();

Thanks,
Vidosh

Jeff Schnitzer

unread,
Jun 8, 2015, 12:27:11 PM6/8/15
to bat...@googlegroups.com
You are trying to use RestFB's java classes with Jackson. RestFB's classes do not have the jackson annotations which map FB's "created_time" to the java field "createdTime". With Jackson you can turn this on globally like so:

facebookBatcher.getMapper().setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);

Arguably this should be the default for BatchFB. I'll make that change.

Jeff
Reply all
Reply to author
Forward
0 new messages