Improve User remove.

This commit is contained in:
sfigato 2019-07-06 21:25:23 +02:00
parent ec472218c4
commit f05fe8a0d5
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F

View File

@ -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):