Skip to content

Commit

Permalink
Fixed some errors when API is unavaliable
Browse files Browse the repository at this point in the history
  • Loading branch information
cubicbyte committed Oct 8, 2023
1 parent e991ac5 commit 72210ec
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bot/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,11 @@ def settings(ctx: ContextManager) -> dict:

# Get chat group name
if ctx.chat_data.get('group_id') is not None:
res = groups_cache.get_group(group_id=ctx.chat_data.get('group_id'))
try:
res = groups_cache.get_group(group_id=ctx.chat_data.get('group_id'))
except HTTPApiException:
res = None

if res is None:
group = lang.get('text.unknown')
else:
Expand Down Expand Up @@ -850,7 +854,7 @@ def students_list(ctx: ContextManager) -> dict:
language=ctx.chat_data.get('lang_code'),
)
except HTTPApiException as err:
if err.response.status_code == 422:
if err.response and err.response.status_code == 422:
return invalid_group(ctx)
return api_unavaliable(ctx)

Expand Down

0 comments on commit 72210ec

Please sign in to comment.