From 46fbd83ac7dc8dfd1cf342c49ed55b1870992d3c Mon Sep 17 00:00:00 2001 From: Anna Waldron Date: Wed, 21 Aug 2019 17:04:46 -0700 Subject: [PATCH] Add error handling for failed connection to database (#129) --- ait/gui/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index faff0812..e93cbae8 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -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]'