tumblr / jumblr

Tumblr API v2 Java Client
Apache License 2.0
278 stars 104 forks source link

Error parsing API error response #91

Open linuxdaemon opened 8 years ago

linuxdaemon commented 8 years ago

When the API itself returns an error, in my case, it was that the queue limit had been reached, the JumblrException class attempts to cast response.errors to a JsonArray, when it is in fact a JsonObject. Tested by building a custom version of Jumblr and adding a print line just before the cast. the response received is '{"errors":{"state":"Can't queue more than 300 posts."}}' and the relevant line is JumblrException.java:83

Linus12 commented 8 years ago

This has caused me numerous problems in debugging errors that are not specific to the API or my code. I now have a switch in place to print the actual error as above that I have to use when I get these problems.

ndtreviv commented 5 years ago

I'm finding also object arrays, eg:

{
    "meta": {
        "status": 404,
        "msg": "Not Found"
    },
    "response": [],
    "errors": [
        {
            "title": "Not Found",
            "code": 4012,
            "detail": "This Tumblr is only viewable within the Tumblr dashboard"
        }
    ]
}

In my case, I'd like to be able to distinguish between blogs that no longer exist, or ones that do exist, but are only available on the Tumblr dashboard, so switching on the error code isn't going to help.