diff --git a/src/phi/async_ldap/model.py b/src/phi/async_ldap/model.py index 3508976..259cf53 100644 --- a/src/phi/async_ldap/model.py +++ b/src/phi/async_ldap/model.py @@ -6,10 +6,16 @@ import typing as T from bonsai import LDAPEntry, LDAPModOp, NoSuchObjectError # type: ignore +from phi.exceptions import ( + PhiAttributeMissing, + PhiEntryDoesNotExist, + PhiEntryExists, + PhiUnauthorized, + PhiUnexpectedRuntimeValue, +) from phi.logging import get_logger from phi.security import hash_pass - log = get_logger(__name__) alog = logging.getLogger("asyncio") alog.setLevel(logging.DEBUG) @@ -321,28 +327,6 @@ class User(Hackers): return match_pass -class PhiEntryExists(Exception): - def __init__(self, dn): - self.dn = dn - - -class PhiEntryDoesNotExist(Exception): - def __init__(self, dn): - self.dn = dn - - -class PhiAttributeMissing(Exception): - def __init__(self, dn, attr): - self.dn = dn - self.attr = attr - - -class PhiUnauthorized(Exception): - def __init__(self, user, *args, **kwargs): - super().__init__(*args, **kwargs) - self.user = user - - class Service(Robots): """ This class models a system user (i.e. users that are ancillary to diff --git a/src/phi/exceptions.py b/src/phi/exceptions.py new file mode 100644 index 0000000..e0f8727 --- /dev/null +++ b/src/phi/exceptions.py @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- + + +class PhiEntryExists(Exception): + def __init__(self, dn): + self.dn = dn + + +class PhiEntryDoesNotExist(Exception): + def __init__(self, dn): + self.dn = dn + + +class PhiAttributeMissing(Exception): + def __init__(self, dn, attr): + self.dn = dn + self.attr = attr + + +class PhiUnauthorized(Exception): + def __init__(self, user, *args, **kwargs): + super().__init__(*args, **kwargs) + self.user = user + + +class PhiUnexpectedRuntimeValue(RuntimeWarning): + def __init__(self, msg, result): + super().__init__(self) + self.msg = msg + self.result = result