Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-add django event handlers, allow for reading out responses in API errors in case something breaks #392

Merged
merged 11 commits into from Aug 6, 2019

Conversation

@jchristgit
Copy link
Member

commented Aug 5, 2019

I nuked the event handlers for some reason.

Actually, I think the reason was that I wrote the new syncers cog which syncs users and roles from the server over to the API (and that made the old handlers doing that irrelevant), and for some reason thought that completely removing the error handler was a good idea. Oh well.

jchristgit added some commits Jul 28, 2019

@SebastiaanZ

This comment has been minimized.

Copy link
Member

commented Aug 5, 2019

When you enter a command that does not exist, e.g. !volcyy, the bot will fall back to polling the API for the existence of a tag. However, if that tag also does not exist, the result raise_for_status is not handled (status=404, obviously):

Ignoring exception in command_error
Traceback (most recent call last):
  File "/home/sebastiaan/.local/share/virtualenvs/djangobot-Oms2CWkR/src/discord-py/discord/client.py", line 225, in _run_event
    await coro(*args, **kwargs)
  File "/home/sebastiaan/pydis/djangobot/bot/cogs/error_handler.py", line 49, in on_command_error
    return await ctx.invoke(tags_get_command, tag_name=ctx.invoked_with)
  File "/home/sebastiaan/.local/share/virtualenvs/djangobot-Oms2CWkR/src/discord-py/discord/ext/commands/context.py", line 127, in invoke
    ret = await command.callback(*arguments, **kwargs)
  File "/home/sebastiaan/pydis/djangobot/bot/cogs/tags.py", line 79, in get_command
    tag = await self.bot.api_client.get(f'bot/tags/{tag_name}')
  File "/home/sebastiaan/pydis/djangobot/bot/api.py", line 36, in get
    self.maybe_raise_for_status(resp, raise_for_status)
  File "/home/sebastiaan/pydis/djangobot/bot/api.py", line 32, in maybe_raise_for_status
    raise ResponseCodeError(response=response)
bot.api.ResponseCodeError

This doesn't happen in the current bot because the raise_for_status is a new feature of the API client.

bot/cogs/error_handler.py Outdated Show resolved Hide resolved
bot/api.py Show resolved Hide resolved
bot/cogs/error_handler.py Show resolved Hide resolved
@jchristgit

This comment has been minimized.

Copy link
Member Author

commented Aug 5, 2019

@SebastiaanZ that's a good point, addressed in bea4e8d.

jchristgit and others added some commits Aug 5, 2019

Fix typo in bot/cogs/error_handler.py.
Originally authored by @MarkKoz.

Co-Authored-By: Mark <kozlovmark@gmail.com>
@MarkKoz

MarkKoz approved these changes Aug 5, 2019

bot/cogs/error_handler.py Show resolved Hide resolved
bot/cogs/error_handler.py Outdated Show resolved Hide resolved

@MarkKoz MarkKoz merged commit a8ef752 into django Aug 6, 2019

3 checks passed

Bot-Django Build #20190805.5 succeeded
Details
Bot-Django (Build containers) Build containers succeeded
Details
Bot-Django (Lint & Test) Lint & Test succeeded
Details

@MarkKoz MarkKoz deleted the django-readd-events branch Aug 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.