mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-07 14:27:54 +00:00
Refactor error handling for system commands
This commit is contained in:
parent
a079db8be0
commit
e95d8a4e0d
3 changed files with 41 additions and 24 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue