3415: API exceptions from Python SDK include more error information.
authorBrett Smith <brett@curoverse.com>
Tue, 5 Aug 2014 19:18:14 +0000 (15:18 -0400)
committerBrett Smith <brett@curoverse.com>
Tue, 5 Aug 2014 19:18:14 +0000 (15:18 -0400)
commitf9d2cd963c314188c0351253c00d6dc82f276ed7
treeb284c87784e389db16faf38aa9c4b6d867b25819
parent46f565cf2dd89a3ec6ad78b1237b3a4b0db6404b
3415: API exceptions from Python SDK include more error information.

The apiclient module doesn't give us a lot of opportunities to
customize error handling.  Request objects can have response
callbacks, but they only get access to the response headers, not body,
which we need to pass along JSON errors.  After that, apiclient.http
imports apiclient.errors.HttpError directly, and raises that directly
whenever there's a permanent error in an HTTP response.

arvados.api already makes a few monkeypatches to apiclient, and this
commit adds one more: it customizes HttpError's __new__ method to
return a new customized subclass instead.  This is pretty evil,
because it will mess with any other instantiations of HttpError in
client programs.  Its only mitigating grace is that the new subclass
is fully API-compatible with the original.
sdk/python/arvados/api.py
sdk/python/arvados/errors.py
sdk/python/tests/test_api.py