Closed andreim789 closed 11 years ago
Hi there. Well if the response from the server suddenly changes there's not much I can do. I'd say that's a bug on bitly's side. Have you talked to them yet? It seems odd that they suddenly return an array instead of an object for "data".
unfortunately bitly's response to this is:
"the value of "data" when status_code != 200 should be treated as undefined (ie: you should not depend on any specific value to catch errors). we will update our documentation to reflect that."
Please have a look at the branch 'issue2' and tell me if this fixes things for you. if it does I'll merge the change into master and release this as 0.7.1
I checked out the issue2 branch and tested it out yesterday it seems to work and handle the errors just fine. Thanks.
Available here, btw. And thanks for testing it.
http://stackmagic.github.io/maven-repo/maven2/net/swisstech/bitly/bitly-api-client/0.7.1/
I tried test case with invalid token, expecting error response from library. But I received Gson parse error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 12
Tracing code I found that server returned following response: { "data": [ ], "status_code": 500, "status_txt": "UNKNOWN_ERROR" }
Normal response looks like: { "status_code": 200, "status_txt": "OK", "data": { ... } }
So element "data" on error from object becomes empty array.
This case should be handled.