[Pulp-list] Catching errors in the CLI
Jay Dobies
jason.dobies at redhat.com
Mon Jun 20 19:19:51 UTC 2011
We've had an outstanding story to clean up exception handling, both
server and client side. One thing to keep in mind for now is to be
consistent in where exceptions are caught. In the client's repo API
module, we have the following methods:
def delete(self, id):
path = "/repositories/%s/" % id
return self.server.DELETE(path)[1]
def clean(self):
path = "/repositories/"
return self.server.DELETE(path)[1]
def sync_list(self, repoid):
path = '/repositories/%s/sync/' % repoid
try:
return self.server.GET(path)[1]
except ServerRequestError:
return []
In nearly all of the client APIs, any errors are bubbled up from the
calls. sync_list should probably follow that model so the caller can
know the difference between a server error and an empty list of syncs.
Until we get a set of rules in place, let's try to be consistent (or
comment on why the consistency is broken in cases where it makes sense).
--
Jay Dobies
RHCE# 805008743336126
Freenode: jdob @ #pulp
http://pulpproject.org | http://blog.pulpproject.org
More information about the Pulp-list
mailing list