Refactor error handling for system commands

This commit is contained in:
Ske
2018-09-09 20:50:53 +02:00
parent a079db8be0
commit e95d8a4e0d
3 changed files with 41 additions and 24 deletions

View File

@@ -65,7 +65,11 @@ class System(namedtuple("System", ["id", "hid", "name", "description", "tag", "a
async def link_account(self, conn, new_account_id: str):
existing_system = await System.get_by_account(conn, new_account_id)
if existing_system:
if existing_system.id == self.id:
raise errors.AccountInOwnSystemError()
raise errors.AccountAlreadyLinkedError(existing_system)
await db.link_account(conn, self.id, new_account_id)