fix(moderation): added logging and error handling for the connect method
All checks were successful
Pylint / Pylint (push) Successful in 1m13s

This commit is contained in:
Seaswimmer 2023-10-04 09:20:39 -04:00
parent 100a5efff2
commit 4c7088eb80
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -41,13 +41,17 @@ class Moderation(commands.Cog):
])
if conf:
raise LookupError
connection = mysql.connector.connect(
host=await self.config.mysql_address(),
user=await self.config.mysql_user(),
password=await self.config.mysql_password(),
database=await self.config.mysql_db()
)
return connection
try:
connection = mysql.connector.connect(
host=await self.config.mysql_address(),
user=await self.config.mysql_user(),
password=await self.config.mysql_password(),
database=await self.config.mysql_db()
)
return connection
except mysql.connector.ProgrammingError as e:
logging.fatal("Unable to access the MySQL database!\nError:\n%s", e)
return e
async def create_guild_table(self, guild: discord.Guild):
database = await self.connect()