1.1 --- a/imiptools/stores/database/postgresql.py Tue Oct 17 23:30:18 2017 +0200
1.2 +++ b/imiptools/stores/database/postgresql.py Wed Oct 18 00:18:37 2017 +0200
1.3 @@ -20,6 +20,7 @@
1.4 """
1.5
1.6 from imiptools.config import settings
1.7 +from imiptools.stores.common import StoreInitialisationError
1.8 from imiptools.stores.database.common import DatabaseStore, DatabaseJournal
1.9 import psycopg2
1.10
1.11 @@ -34,7 +35,11 @@
1.12
1.13 "Interpret 'store_dir' as a connection string."
1.14
1.15 - connection = psycopg2.connect(store_dir or STORE_DIR)
1.16 + try:
1.17 + connection = psycopg2.connect(store_dir or STORE_DIR)
1.18 + except psycopg2.OperationalError, exc:
1.19 + raise StoreInitialisationError, exc
1.20 +
1.21 connection.autocommit = True
1.22 DatabaseStore.__init__(self, connection, psycopg2.paramstyle)
1.23
1.24 @@ -54,7 +59,11 @@
1.25
1.26 "Interpret 'store_dir' as a connection string."
1.27
1.28 - connection = psycopg2.connect(store_dir or JOURNAL_DIR)
1.29 + try:
1.30 + connection = psycopg2.connect(store_dir or JOURNAL_DIR)
1.31 + except psycopg2.OperationalError, exc:
1.32 + raise StoreInitialisationError, exc
1.33 +
1.34 connection.autocommit = True
1.35 DatabaseJournal.__init__(self, connection, psycopg2.paramstyle)
1.36