add logging to Exception

This commit is contained in:
Philipp 2022-10-07 19:53:34 +02:00
parent 64e4572e73
commit 4fc4b6a018
Signed by: Philipp
GPG key ID: 9EBD8439AFBAB750

View file

@ -24,6 +24,9 @@ class Database:
logger.info(f"Connection to mysql got interrupted, trying to reconnect...") logger.info(f"Connection to mysql got interrupted, trying to reconnect...")
self.con.reconnect() self.con.reconnect()
self.init_test_database() self.init_test_database()
except Exception as err:
logger.error(f"Database interrupted: {err}")
raise Exception("Error while trying to connect to database.")
def create_reserved_slot(self, discord_user, steam_id): def create_reserved_slot(self, discord_user, steam_id):
cursor = self.con.cursor() cursor = self.con.cursor()
@ -46,3 +49,6 @@ class Database:
self.create_reserved_slot(discord_user, steam_id) self.create_reserved_slot(discord_user, steam_id)
except mysql.connector.IntegrityError: except mysql.connector.IntegrityError:
raise Exception("Duplicate entrys") raise Exception("Duplicate entrys")
except Exception as err:
logger.error(f"Database interrupted: {err}")
raise Exception("Error while trying to connect to database.")