catch database connection errors
This commit is contained in:
parent
83ece2c59e
commit
d956760e4c
1 changed files with 10 additions and 5 deletions
|
@ -93,12 +93,17 @@ async def query_database():
|
||||||
global database
|
global database
|
||||||
global rechead
|
global rechead
|
||||||
db_url = f'https://{scheduler_hostname}/database'
|
db_url = f'https://{scheduler_hostname}/database'
|
||||||
if requests.get(db_url).status_code == 200:
|
try:
|
||||||
response = requests.get(db_url)
|
if requests.get(db_url).status_code == 200:
|
||||||
response.raise_for_status()
|
response = requests.get(db_url)
|
||||||
database = response.json()
|
response.raise_for_status()
|
||||||
else:
|
database = response.json()
|
||||||
|
else:
|
||||||
|
logger_discord.error('Cannot connect to the database!')
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
logger_discord.error('Cannot connect to the database!')
|
logger_discord.error('Cannot connect to the database!')
|
||||||
|
logger_discord.error(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
if database == {}:
|
if database == {}:
|
||||||
|
|
Loading…
Reference in a new issue