Skip to content

Commit ca2cc9d

Browse files
committed
Add better error messages for db faliures
1 parent 23cf9c5 commit ca2cc9d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

bot.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,23 @@ async def validate_database_connection(self):
903903
except Exception as exc:
904904
logger.critical(error('Something went wrong '
905905
'while connecting to the database.'))
906-
logger.critical(error(f'{type(exc).__name__}: {str(exc)}'))
906+
message = f'{type(exc).__name__}: {str(exc)}'
907+
logger.critical(error(message))
908+
909+
if 'ServerSelectionTimeoutError' in message:
910+
logger.critical(error(
911+
"This may have been caused by not whitelisting "
912+
"IPs correctly. Make sure to whitelist all "
913+
"IPs (0.0.0.0/0) https://i.imgur.com/mILuQ5U.png"
914+
))
915+
916+
if 'OperationFailure' in message:
917+
logger.critical(error("This is due to having invalid credentials in your MONGO_URI."))
918+
logger.critical(error(
919+
"Recheck the username/password and make sure to url encode them. "
920+
"https://www.urlencoder.io/"
921+
))
922+
907923
return await self.logout()
908924
else:
909925
logger.info(info('Successfully connected to the database.'))

0 commit comments

Comments
 (0)