Skip to content

Commit

Permalink
Add error handling for failed connection to database (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
aywaldron committed Aug 22, 2019
1 parent 923cf61 commit 46fbd83
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ait/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,15 @@ def _db_connect(self):
break

if datastore:
mod, cls = datastore.rsplit('.', 1)

# Connect to database
self.dbconn = getattr(importlib.import_module(mod), cls)()
self.dbconn.connect(**other_args)
try:
mod, cls = datastore.rsplit('.', 1)

# Connect to database
self.dbconn = getattr(importlib.import_module(mod), cls)()
self.dbconn.connect(**other_args)
except Exception as e:
log.error('Error connecting to datastore {}: {}'.format(datastore, e))
log.warn('Disabling telemetry playback.')
else:
msg = (
'[GUI Playback Configuration]'
Expand Down

0 comments on commit 46fbd83

Please sign in to comment.