fixed error handling for edit commands
parent
5b0027668b
commit
f8c4009f19
19
Commands.py
19
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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue