1
0
Fork 0
mirror of synced 2024-06-01 18:29:38 +12:00

Printing full traceback for error testing

This commit is contained in:
phxntxm 2016-07-15 18:16:00 -05:00
parent 5e0f8d370a
commit 59c6fcc868

7
bot.py
View file

@ -64,10 +64,9 @@ async def on_command_error(error, ctx):
fmt = "You can't tell me what to do!"
await bot.send_message(ctx.message.channel, fmt)
elif isinstance(error, commands.CommandInvokeError):
fmt = 'In {0.command.qualified_name}:'.format(ctx)
fmt += error.original.__traceback__
fmt += '{0.__class__.__name__}: {0}'.format(error.original)
await bot.send_message(ctx.message.channel,"```{}```".format(fmt))
print('In {0.command.qualified_name}:'.format(ctx), file=sys.stderr)
traceback.print_tb(error.original.__traceback__)
print('{0.__class__.__name__}: {0}'.format(error.original), file=sys.stderr)
else:
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
await bot.send_message(ctx.message.channel, fmt.format(type(error).__name__, error))