{"action":"created","issue":{"url":"https://api.github.com/repos/restfb/restfb/issues/80","labels_url":"https://api.github.com/repos/restfb/restfb/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/restfb/restfb/issues/80/comments","events_url":"https://api.github.com/repos/restfb/restfb/issues/80/events","html_url":"https://github.com/restfb/restfb/issues/80","id":17679190,"number":80,"title":"Make throwFacebookResponseStatusExceptionIfNecessary in DefaultFacebookClient public???","user":{"login":"slumx","id":1569911,"avatar_url":"https://avatars.githubusercontent.com/u/1569911?v=3","gravatar_id":"","url":"https://api.github.com/users/slumx","html_url":"https://github.com/slumx","followers_url":"https://api.github.com/users/slumx/followers","following_url":"https://api.github.com/users/slumx/following{/other_user}","gists_url":"https://api.github.com/users/slumx/gists{/gist_id}","starred_url":"https://api.github.com/users/slumx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slumx/subscriptions","organizations_url":"https://api.github.com/users/slumx/orgs","repos_url":"https://api.github.com/users/slumx/repos","events_url":"https://api.github.com/users/slumx/events{/privacy}","received_events_url":"https://api.github.com/users/slumx/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/restfb/restfb/labels/Breaking%20Change","name":"Breaking Change","color":"fad8c7"},{"url":"https://api.github.com/repos/restfb/restfb/labels/type:%20improvement","name":"type: improvement","color":"b3f6b3"}],"state":"closed","locked":false,"assignee":{"login":"nbartels","id":1113969,"avatar_url":"https://avatars.githubusercontent.com/u/1113969?v=3","gravatar_id":"","url":"https://api.github.com/users/nbartels","html_url":"https://github.com/nbartels","followers_url":"https://api.github.com/users/nbartels/followers","following_url":"https://api.github.com/users/nbartels/following{/other_user}","gists_url":"https://api.github.com/users/nbartels/gists{/gist_id}","starred_url":"https://api.github.com/users/nbartels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbartels/subscriptions","organizations_url":"https://api.github.com/users/nbartels/orgs","repos_url":"https://api.github.com/users/nbartels/repos","events_url":"https://api.github.com/users/nbartels/events{/privacy}","received_events_url":"https://api.github.com/users/nbartels/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/restfb/restfb/milestones/16","html_url":"https://github.com/restfb/restfb/milestones/2.0.0","labels_url":"https://api.github.com/repos/restfb/restfb/milestones/16/labels","id":1118115,"number":16,"title":"2.0.0","description":"","creator":{"login":"nbartels","id":1113969,"avatar_url":"https://avatars.githubusercontent.com/u/1113969?v=3","gravatar_id":"","url":"https://api.github.com/users/nbartels","html_url":"https://github.com/nbartels","followers_url":"https://api.github.com/users/nbartels/followers","following_url":"https://api.github.com/users/nbartels/following{/other_user}","gists_url":"https://api.github.com/users/nbartels/gists{/gist_id}","starred_url":"https://api.github.com/users/nbartels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbartels/subscriptions","organizations_url":"https://api.github.com/users/nbartels/orgs","repos_url":"https://api.github.com/users/nbartels/repos","events_url":"https://api.github.com/users/nbartels/events{/privacy}","received_events_url":"https://api.github.com/users/nbartels/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":9,"state":"open","created_at":"2015-05-19T12:56:33Z","updated_at":"2015-11-29T16:21:38Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2013-08-06T08:55:44Z","updated_at":"2015-11-29T17:11:08Z","closed_at":"2015-11-29T16:21:38Z","body":"When doing batch requests it would be nice to be able to call throwFacebookResponseStatusExceptionIfNecessary, so you don't have to duplicate all the code which is already written.\r\n\r\nThe downside of this is that you can't use the abstraction of the FacebookClient interface anymore. Maybe the exception handling could be moved to a utility class which could be public accessible?\r\n\r\nIf know it's a lot to ask. I would be happy to help if we could could agree on the right way to implement this feature...\r\n\r\nHere is a quite dirty hack, but it should work:\r\n\r\n```\r\nclass RestFbExceptionHelper extends DefaultFacebookClient {\r\n\t\r\n\tprotected void throwFacebookResponseStatusExceptionIfNecessary(String json, Integer httpStatusCode) {\r\n\t\tsuper.throwFacebookResponseStatusExceptionIfNecessary(json, httpStatusCode);\r\n\t}\r\n}\r\n```\r\n\r\n```\r\npublic class RestFbExceptionUtils {\r\n\t\r\n\tprivate static final RestFbExceptionHelper restFbExceptionHelper = new RestFbExceptionHelper();\r\n\t\r\n\tpublic static void throwFacebookResponseStatusExceptionIfNecessary(String json, Integer httpStatusCode) {\r\n\t\trestFbExceptionHelper.throwFacebookResponseStatusExceptionIfNecessary(json, httpStatusCode);\r\n\t}\r\n}\r\n```\r\n\r\nWhen processing larger results the error checking can also take quite some time up to 150ms (depends on hardware ;-)) this could maybe be optimized by adding a little string test in throwFacebookResponseStatusExceptionIfNecessary after testing for \"{\" something like:\r\n\r\n```\r\nint subStrEnd = Math.min(50, json.length());\r\nif (json.substring(0, subStrEnd).indexOf(\"\\\"error\\\"\") == -1) {\r\n\treturn; //no need to parse json\r\n}\r\n```\r\n\r\nThis gives a constant performance below 1ms no matter how large the json result is."},"comment":{"url":"https://api.github.com/repos/restfb/restfb/issues/comments/160432553","html_url":"https://github.com/restfb/restfb/issues/80#issuecomment-160432553","issue_url":"https://api.github.com/repos/restfb/restfb/issues/80","id":160432553,"user":{"login":"slumx","id":1569911,"avatar_url":"https://avatars.githubusercontent.com/u/1569911?v=3","gravatar_id":"","url":"https://api.github.com/users/slumx","html_url":"https://github.com/slumx","followers_url":"https://api.github.com/users/slumx/followers","following_url":"https://api.github.com/users/slumx/following{/other_user}","gists_url":"https://api.github.com/users/slumx/gists{/gist_id}","starred_url":"https://api.github.com/users/slumx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slumx/subscriptions","organizations_url":"https://api.github.com/users/slumx/orgs","repos_url":"https://api.github.com/users/slumx/repos","events_url":"https://api.github.com/users/slumx/events{/privacy}","received_events_url":"https://api.github.com/users/slumx/received_events","type":"User","site_admin":false},"created_at":"2015-11-29T17:11:08Z","updated_at":"2015-11-29T17:11:08Z","body":"I would still need to do all the parsing and checking done inthrowFacebookResponseStatusExceptionIfNecessary myself?? \r\n"}}