Move custom exceptions in own module
This commit is contained in:
parent
a0cf7e9603
commit
12f37b3a55
|
@ -6,10 +6,16 @@ import typing as T
|
||||||
|
|
||||||
from bonsai import LDAPEntry, LDAPModOp, NoSuchObjectError # type: ignore
|
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.logging import get_logger
|
||||||
from phi.security import hash_pass
|
from phi.security import hash_pass
|
||||||
|
|
||||||
|
|
||||||
log = get_logger(__name__)
|
log = get_logger(__name__)
|
||||||
alog = logging.getLogger("asyncio")
|
alog = logging.getLogger("asyncio")
|
||||||
alog.setLevel(logging.DEBUG)
|
alog.setLevel(logging.DEBUG)
|
||||||
|
@ -321,28 +327,6 @@ class User(Hackers):
|
||||||
return match_pass
|
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):
|
class Service(Robots):
|
||||||
"""
|
"""
|
||||||
This class models a system user (i.e. users that are ancillary to
|
This class models a system user (i.e. users that are ancillary to
|
||||||
|
|
30
src/phi/exceptions.py
Normal file
30
src/phi/exceptions.py
Normal file
|
@ -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
|
Loading…
Reference in New Issue
Block a user