{"action":"opened","issue":{"url":"https://api.github.com/repos/gocardless/gocardless-python/issues/25","labels_url":"https://api.github.com/repos/gocardless/gocardless-python/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/gocardless/gocardless-python/issues/25/comments","events_url":"https://api.github.com/repos/gocardless/gocardless-python/issues/25/events","html_url":"https://github.com/gocardless/gocardless-python/issues/25","id":69591293,"number":25,"title":"Server returning json blob containing key named \"errors\", code looks for key named \"error\"","user":{"login":"nehresma","id":228009,"avatar_url":"https://avatars.githubusercontent.com/u/228009?v=3","gravatar_id":"","url":"https://api.github.com/users/nehresma","html_url":"https://github.com/nehresma","followers_url":"https://api.github.com/users/nehresma/followers","following_url":"https://api.github.com/users/nehresma/following{/other_user}","gists_url":"https://api.github.com/users/nehresma/gists{/gist_id}","starred_url":"https://api.github.com/users/nehresma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nehresma/subscriptions","organizations_url":"https://api.github.com/users/nehresma/orgs","repos_url":"https://api.github.com/users/nehresma/repos","events_url":"https://api.github.com/users/nehresma/events{/privacy}","received_events_url":"https://api.github.com/users/nehresma/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-20T13:50:47Z","updated_at":"2015-04-20T13:50:47Z","closed_at":null,"body":"In the sandbox, I created a test pre-authorization with a monthly max of 5000 GBP.  I ran several tests through just fine, but suddenly started getting errors back.\r\n\r\nLooking into it, I see that the pre-auth limit has been reached on my test, but the error being raised is a KeyError on an 'id' field.  This is because the server returns a json blob that looks like:\r\n\r\n    '{\"errors\":{\"pre_authorization\":[\"maximum amount exceeded for the period 2015-04-20 00:00:00 UTC..2015-05-19 23:59:59 UTC (GBP725.0 requested, only GBP600.0 remaining).\"]}}'\r\n\r\nThe code in client.py looks for a key named \"error\", which doesn't exist.  So it doesn't raise the ClientError about exceeding the limit:\r\n\r\n        if type(response) == dict and \"error\" in response.keys():\r\n            raise ClientError(\"Error calling api, message was {0}\".format(\r\n                response[\"error\"]))\r\n\r\nhttps://github.com/gocardless/gocardless-python/blob/master/gocardless/client.py#L119\r\n\r\nSince this is in the Client class, this problem probably isn't isolated to this particular error."}}