diff options
author | Martin Babinsky <mbabinsk@redhat.com> | 2015-11-20 13:47:34 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2015-12-21 12:05:23 +0100 |
commit | cd5fa389450d15d5bc696131f73d062000d3558f (patch) | |
tree | 92bfddf529d5b772456d5e7ea9bc1187d83fec9e /ipalib/backend.py | |
parent | aa648bcedcdb06162f1e578731ecf7fba299b709 (diff) | |
download | freeipa-cd5fa389450d15d5bc696131f73d062000d3558f.tar.gz freeipa-cd5fa389450d15d5bc696131f73d062000d3558f.tar.xz freeipa-cd5fa389450d15d5bc696131f73d062000d3558f.zip |
raise more descriptive Backend connection-related exceptions
https://fedorahosted.org/freeipa/ticket/5473
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipalib/backend.py')
-rw-r--r-- | ipalib/backend.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/ipalib/backend.py b/ipalib/backend.py index b8fa29626..342e17ec5 100644 --- a/ipalib/backend.py +++ b/ipalib/backend.py @@ -57,8 +57,10 @@ class Connectible(Backend): """ if hasattr(context, self.id): raise Exception( - "connect: 'context.%s' already exists in thread %r" % ( - self.id, threading.currentThread().getName() + "{0} is already connected ({1} in {2})".format( + self.name, + self.id, + threading.currentThread().getName() ) ) conn = self.create_connection(*args, **kw) @@ -72,8 +74,10 @@ class Connectible(Backend): def disconnect(self): if not hasattr(context, self.id): raise Exception( - "disconnect: 'context.%s' does not exist in thread %r" % ( - self.id, threading.currentThread().getName() + "{0} is not connected ({1} in {2})".format( + self.name, + self.id, + threading.currentThread().getName() ) ) self.destroy_connection() @@ -94,8 +98,12 @@ class Connectible(Backend): Return thread-local connection. """ if not hasattr(context, self.id): - raise AttributeError('no context.%s in thread %r' % ( - self.id, threading.currentThread().getName()) + raise AttributeError( + "{0} is not connected ({1} in {2})".format( + self.name, + self.id, + threading.currentThread().getName() + ) ) return getattr(context, self.id).conn conn = property(__get_conn) |