fix(moderation): added logging and error handling for the connect method
All checks were successful
Pylint / Pylint (push) Successful in 1m13s
All checks were successful
Pylint / Pylint (push) Successful in 1m13s
This commit is contained in:
parent
100a5efff2
commit
4c7088eb80
1 changed files with 11 additions and 7 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue