1
0
Fork 0
mirror of synced 2024-06-18 18:44:33 +12:00

Printing full traceback for error testing

This commit is contained in:
phxntxm 2016-07-15 18:13:12 -05:00
parent 227a09e566
commit 347da70ed0

7
bot.py
View file

@ -63,9 +63,10 @@ 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):
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)
fmt = 'In {0.command.qualified_name}:'.format(ctx), file=sys.stderr
fmt += error.original.__traceback__
fmt += '{0.__class__.__name__}: {0}'.format(error.original), file=sys.stderr
await bot.send_message(ctx.message.channel,"```{}```".format(fmt))
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))