Improve User remove.
This commit is contained in:
parent
ec472218c4
commit
f05fe8a0d5
|
@ -4,7 +4,7 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
import typing as T
|
import typing as T
|
||||||
|
|
||||||
from bonsai import LDAPEntry, LDAPModOp
|
from bonsai import LDAPEntry, LDAPModOp, NoSuchObjectError
|
||||||
|
|
||||||
from phi.logging import get_logger
|
from phi.logging import get_logger
|
||||||
|
|
||||||
|
@ -286,7 +286,10 @@ class User(Hackers):
|
||||||
async def remove(self):
|
async def remove(self):
|
||||||
async with self.client.connect(is_async=True) as conn:
|
async with self.client.connect(is_async=True) as conn:
|
||||||
self._entry.connection = conn
|
self._entry.connection = conn
|
||||||
await self._entry.delete()
|
try:
|
||||||
|
await self._entry.delete()
|
||||||
|
except NoSuchObjectError:
|
||||||
|
raise PhiUserDoesNotExist
|
||||||
|
|
||||||
|
|
||||||
class PhiUserExists(Exception):
|
class PhiUserExists(Exception):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user