trouble with transparency of exception mappings

39 views
Skip to first unread message

smartnut007

unread,
Aug 2, 2012, 1:17:04 PM8/2/12
to bat...@googlegroups.com
hi guys, 

I am using version 2.1.2 release.

1) I get this following exception in my code. But, i was hoping to at least have the actual facebook error messages logged. But, interestingly there are no loggers in batchfb. That is fine. But, in this case I would like to go lower and see what the http code and the response body. 

2) Another thing i dont get is that the exception trace says it was thrown at ErrorDetectingWrapper.java:112 . But, as you can look at the code snippet below, that line 112 is wrapped in an umbrella exception catch. So, shouldn't any exception have been thrown from line 114 or 116 instead ? 

3) What sort of exceptions are thrown by fb with regards to any api limits being exceeded ? And are they explicitly being mapped to anything by batchfb. 

com.googlecode.batchfb.err.OAuthException: An unexpected error has occurred. Please retry your request later.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0_33]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) ~[na:1.6.0_33]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) ~[na:1.6.0_33]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_33]
at com.googlecode.batchfb.impl.ErrorDetectingWrapper.checkForStandardGraphError(ErrorDetectingWrapper.java:112) ~[batchfb-2.1.2.jar:February 22 2012]
at com.googlecode.batchfb.impl.ErrorDetectingWrapper.convert(ErrorDetectingWrapper.java:67) ~[batchfb-2.1.2.jar:February 22 2012]
at com.googlecode.batchfb.impl.ErrorDetectingWrapper.convert(ErrorDetectingWrapper.java:53) ~[batchfb-2.1.2.jar:February 22 2012]
at com.googlecode.batchfb.util.LaterWrapper.get(LaterWrapper.java:45) ~[batchfb-2.1.2.jar:February 22 2012]
at com.googlecode.batchfb.util.LaterWrapper.get(LaterWrapper.java:45) ~[batchfb-2.1.2.jar:February 22 2012]
at com.googlecode.batchfb.util.LaterWrapper.get(LaterWrapper.java:45) ~[batchfb-2.1.2.jar:February 22 2012]
at org.fetch.FullCycle.main(FullCycle.java:52) ~[classes/:na]

************* ErrorDetectingWrapper.java ***************
109: try { 
110:    Class<?> exceptionClass = Class.forName(proposedExceptionType);
111:    Constructor<?> ctor = exceptionClass.getConstructor(String.class);
112:    throw (FacebookException)ctor.newInstance(msg);
113: } catch (FacebookException e) { 
114:    throw e;
115: } catch (Exception e) {  
116:    throw new FacebookException(type + ": " + msg);
117: }

*****************************

smartnut007

unread,
Aug 2, 2012, 1:18:46 PM8/2/12
to bat...@googlegroups.com
And I am pretty sure my token had not expired. 

Jeff Schnitzer

unread,
Aug 2, 2012, 2:17:20 PM8/2/12
to bat...@googlegroups.com
Unfortunately I am literally about to run out the door and will be
offline for a few days, so I can't look too deep. But I will try:

On Thu, Aug 2, 2012 at 10:17 AM, smartnut007
<sinchron...@gmail.com> wrote:
> hi guys,
>
> I am using version 2.1.2 release.
>
> 1) I get this following exception in my code. But, i was hoping to at least
> have the actual facebook error messages logged. But, interestingly there are
> no loggers in batchfb. That is fine. But, in this case I would like to go
> lower and see what the http code and the response body.

BatchFB logs the raw request and response via java.util.logging - see
RequestBuilder. Turn this on in your logging.properties:

com.googlecode.batchfb.level = FINEST

> 2) Another thing i dont get is that the exception trace says it was thrown
> at ErrorDetectingWrapper.java:112 . But, as you can look at the code snippet
> below, that line 112 is wrapped in an umbrella exception catch. So,
> shouldn't any exception have been thrown from line 114 or 116 instead ?

Just to eliminate any potential problems, I recommend checking out and
building trunk. It's overdue for an official release anyways. Note
that it uses Jackson 2.0.

> 3) What sort of exceptions are thrown by fb with regards to any api limits
> being exceeded ? And are they explicitly being mapped to anything by
> batchfb.

I really don't know. Facebook changes their exceptions now and then.
If you find they produce a particular exception message in that case,
it's trivial to add a typed exception for it - just add the exception
class to the err package and BatchFB will pick it up.

Sorry - I hope that gets you started. I'll be back online in a few days.

Jeff

smartnut007

unread,
Aug 6, 2012, 2:51:39 PM8/6/12
to bat...@googlegroups.com, je...@infohazard.org
I was able to turn on logging and that was helpful. I get something like 
OAuthException  #613  600 requests in 600 seconds exceeded. 

What would be helpful is also the http response code from facebook. I havent had time to look into the code. But, will do so if i have time and make that change. 

I appreciate this library. But, minor things. There is only 2 open source libraries among 150 in our projects that is not on maven. Yours is one of them :-). have you considered making that jump ? I can help a bit if you need. 

Also, if you are not aware for slf4j users, integrating a library using jul is a huge performance penalty. 

thanks
Arun

Jeff Schnitzer

unread,
Aug 6, 2012, 4:40:08 PM8/6/12
to bat...@googlegroups.com
On Mon, Aug 6, 2012 at 11:51 AM, smartnut007
<sinchron...@gmail.com> wrote:
> I was able to turn on logging and that was helpful. I get something like
> OAuthException #613 600 requests in 600 seconds exceeded.
>
> What would be helpful is also the http response code from facebook. I havent
> had time to look into the code. But, will do so if i have time and make that
> change.

Unfortunately this is not an easy one to make; the entire asynchronous
chain of futures is based on Later<JsonNode>. There is no convenient
in-band place to pass that extra bit of metadata.

Is this really important? What case do you need to distinguish via
http code that is different from the detected exceptions?

> I appreciate this library. But, minor things. There is only 2 open source
> libraries among 150 in our projects that is not on maven. Yours is one of
> them :-). have you considered making that jump ? I can help a bit if you
> need.

I loathe Maven. That said, I don't have any great objection to
creating a pom and pushing the project to maven central. For that
matter I'm overdue for converting the repository to git.

Would you like to revise the build system?

> Also, if you are not aware for slf4j users, integrating a library using jul
> is a huge performance penalty.

I use slf4j myself in most projects. However, I would rather not add
another jar dependency just for logging.

Since batchfb only logs requests and responses, the overhead of
logging should be dwarfed by the expense of issuing and processing the
request. If I'm wrong about that (I would be very surprised), we can
add the slf4j dependency.

Jeff
Reply all
Reply to author
Forward
0 new messages