Improve User remove.

refactor
blallo 2019-07-06 21:25:23 +02:00
parent ec472218c4
commit f05fe8a0d5
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
1 changed files with 5 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import asyncio
import logging
import typing as T
from bonsai import LDAPEntry, LDAPModOp
from bonsai import LDAPEntry, LDAPModOp, NoSuchObjectError
from phi.logging import get_logger
@ -286,7 +286,10 @@ class User(Hackers):
async def remove(self):
async with self.client.connect(is_async=True) as conn:
self._entry.connection = conn
await self._entry.delete()
try:
await self._entry.delete()
except NoSuchObjectError:
raise PhiUserDoesNotExist
class PhiUserExists(Exception):