diff --git a/Commands.py b/Commands.py index 3e9cb45..013439b 100644 --- a/Commands.py +++ b/Commands.py @@ -192,6 +192,12 @@ class Commands: session.commit() loc_str = location.__str__() + except IntegrityError: + session.rollback() + raise EntryNameNotUniqueError + except DataError: + session.rollback() + raise DatabaseValueError except IndexError: raise LocationLookUpError finally: @@ -215,6 +221,12 @@ class Commands: loc_str = location.__str__() session.commit() + except IntegrityError: + session.rollback() + raise EntryNameNotUniqueError + except DataError: + session.rollback() + raise DatabaseValueError except IndexError: raise LocationLookUpError finally: @@ -232,6 +244,13 @@ class Commands: location.name = new_name loc_str = location.__str__() session.commit() + + except IntegrityError: + session.rollback() + raise EntryNameNotUniqueError + except DataError: + session.rollback() + raise DatabaseValueError except IndexError: raise LocationLookUpError finally: diff --git a/Geoffrey.py b/Geoffrey.py index 4d359a6..e8fe9f4 100644 --- a/Geoffrey.py +++ b/Geoffrey.py @@ -355,6 +355,8 @@ async def edit_tunnel(ctx, tunnel_color: str, tunnel_number: int, * args): except LocationLookUpError: await bot.say('{}, you do not have a location called **{}**.'.format( ctx.message.author.mention, loc)) + except InvalidTunnelError: + await bot.say('{}, {} is an invalid tunnel color.'.format(ctx.message.author.mention, tunnel_color)) @commands.cooldown(5, 60, commands.BucketType.user) @bot.command(pass_context=True)