Skip to content

Commit

Permalink
add some more logging in on_command_error/pull fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
TicClick committed Apr 20, 2021
1 parent ba3eb12 commit 92e0f87
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 12 additions & 2 deletions librarian/discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,24 @@ def __init__(

super().__init__(*args, command_prefix=self.COMMAND_PREFIX, **kwargs)

async def on_command_error(self, ctx, exception):
async def _on_command_error_inner(self, ctx, exception):
if isinstance(exception, commands_errors.CommandNotFound):
return await ctx.message.channel.send(
content="no such command `{}` -- try `{}help` instead".format(
ctx.invoked_with, self.COMMAND_PREFIX
)
)
return await super().on_command_error(ctx, exception)
else:
return await super().on_command_error(ctx, exception)

async def on_command_error(self, ctx, exception):
try:
return await self._on_command_error_inner(ctx, exception)
except discord.errors.DiscordException as new_exc:
logger.info(
"Failed to notify %r in #%d about the error %r: %s",
ctx.message.author, ctx.message.channel.id, exception, new_exc
)

def setup(self):
self.add_cog(pulls.Pulls())
Expand Down
5 changes: 4 additions & 1 deletion librarian/discord/cogs/background/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ async def fetch_pulls(self, numbers: typing.Set[int]) -> typing.List[dict]:
if isinstance(result, Exception):
logger.error("%s: couldn't fetch pull #%s: %s", self.name, number, result)
else:
ok.append(result)
if result is None:
logger.error("%s: received None for a pull #%d during fetching", self.name, result)
else:
ok.append(result)
return ok

@tasks.loop(seconds=INTERVAL)
Expand Down

0 comments on commit 92e0f87

Please sign in to comment.