[2/3] Catch errors when we try to parse our config

Message ID 20171010135525.1102-2-jonatan.schlag@ipfire.org
State New
Headers show
Series
  • [1/3] Load configurations only if the config file exists
Related show

Commit Message

Jonatan Schlag Oct. 11, 2017, 12:55 a.m. UTC
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 src/buildservice/__init__.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Patch

diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py
index 9619bfe..7a744f5 100644
--- a/src/buildservice/__init__.py
+++ b/src/buildservice/__init__.py
@@ -94,10 +94,13 @@  class Backend(object):
 
 	@lazy_property
 	def db(self):
-		name     = self.config.get("database", "name")
-		hostname = self.config.get("database", "hostname")
-		user     = self.config.get("database", "user")
-		password = self.config.get("database", "password")
+		try:
+			name     = self.config.get("database", "name")
+			hostname = self.config.get("database", "hostname")
+			user     = self.config.get("database", "user")
+			password = self.config.get("database", "password")
+		except ConfigParser.Error as e:
+			log.error("Error parsing the config: %s" % e.message)
 
 		log.debug("Connecting to database %s @ %s" % (name, hostname))