Fixed issue in sending error messages.

doc_update
Joey Hines 2018-07-22 19:01:49 -05:00
parent 93827f5f90
commit a13e1c9af2
2 changed files with 3 additions and 8 deletions

View File

@ -44,9 +44,6 @@ class Commands:
base = self.interface.add_base(session, player, base_name, x_pos, z_pos) base = self.interface.add_base(session, player, base_name, x_pos, z_pos)
base_name = base.name base_name = base.name
except EntryNameNotUniqueError:
session.rollback()
raise EntryNameNotUniqueError
finally: finally:
session.close() session.close()
@ -81,9 +78,6 @@ class Commands:
tunnel = self.interface.add_tunnel(session, player, tunnel_color, tunnel_number, location_name) tunnel = self.interface.add_tunnel(session, player, tunnel_color, tunnel_number, location_name)
tunnel_info = tunnel.__str__() tunnel_info = tunnel.__str__()
except EntryNameNotUniqueError:
session.rollback()
raise EntryNameNotUniqueError
finally: finally:
session.close() session.close()

View File

@ -44,11 +44,12 @@ async def on_command_error(error, ctx):
elif isinstance(error.original, EntryNameNotUniqueError): elif isinstance(error.original, EntryNameNotUniqueError):
error_str = 'An entry in the database already has that name ding dong.' error_str = 'An entry in the database already has that name ding dong.'
elif isinstance(error.original, DatabaseValueError): elif isinstance(error.original, DatabaseValueError):
error_str = 'Use a shorter name or a smaller value, dong ding.' error_str = 'Use a shorter name or a smaller value, dong ding.'
else: else:
error_str = bad_error_message.format(ctx.invoked_with, error) error_str = bad_error_message.format(ctx.invoked_with, error)
bot.send_message(ctx.message.channel, '**Error Running Command:** {}'.format(error_str)) await bot.send_message(ctx.message.channel, '{} **Error Running Command:** {}'.format(ctx.message.author.mention,
error_str))
@bot.command() @bot.command()