summaryrefslogtreecommitdiff
path: root/tooz/drivers/pgsql.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2015-04-14 16:01:03 -0700
committerJoshua Harlow <harlowja@gmail.com>2015-04-14 23:26:12 -0700
commitedd499fdc571ab4b2bda7e79a6f2cbcdb256273e (patch)
tree7c8ae20a380226167cf31733d4aedcaf431d3fef /tooz/drivers/pgsql.py
parenta0980f8a95734cdbe60293f5f057ae26252a10da (diff)
downloadtooz-edd499fdc571ab4b2bda7e79a6f2cbcdb256273e.tar.gz
Add + use helper to raise + chain exceptions
Ensure that on python versions that can retain the exceptions associated chain/causes that we make an attempt to retain them, on versions of python that do not have this at least attempt to retain the chain (but we will not get the nice stack formatting that comes along with that). Change-Id: I7b46854c3969463009c39be28a3131d2d3179c82
Diffstat (limited to 'tooz/drivers/pgsql.py')
-rw-r--r--tooz/drivers/pgsql.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tooz/drivers/pgsql.py b/tooz/drivers/pgsql.py
index 548a99d..b5abca5 100644
--- a/tooz/drivers/pgsql.py
+++ b/tooz/drivers/pgsql.py
@@ -83,7 +83,9 @@ def _translating_cursor(conn):
with conn.cursor() as cur:
yield cur
except psycopg2.Error as e:
- raise coordination.ToozError(_format_exception(e))
+ coordination.raise_with_cause(coordination.ToozError,
+ _format_exception(e),
+ cause=e)
class PostgresLock(locking.Lock):
@@ -209,4 +211,6 @@ class PostgresDriver(coordination.CoordinationDriver):
password=password,
database=dbname)
except psycopg2.Error as e:
- raise coordination.ToozConnectionError(_format_exception(e))
+ coordination.raise_with_cause(coordination.ToozConnectionError,
+ _format_exception(e),
+ cause=e)