mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-06 11:57:23 +00:00
Refactor: fix admin exception (#10400)
### What problem does this PR solve? As title ### Type of change - [x] Refactoring Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
parent
dfc5fa1f4d
commit
ef0aecea3b
@ -8,6 +8,7 @@ from api.db.services.user_service import TenantService
|
|||||||
from api.db.services.knowledgebase_service import KnowledgebaseService
|
from api.db.services.knowledgebase_service import KnowledgebaseService
|
||||||
from api.utils.crypt import decrypt
|
from api.utils.crypt import decrypt
|
||||||
from api.utils import health_utils
|
from api.utils import health_utils
|
||||||
|
|
||||||
from api.common.exceptions import AdminException, UserAlreadyExistsError, UserNotFoundError
|
from api.common.exceptions import AdminException, UserAlreadyExistsError, UserNotFoundError
|
||||||
from config import SERVICE_CONFIGS
|
from config import SERVICE_CONFIGS
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,21 @@
|
|||||||
class AdminException(Exception):
|
class AdminException(Exception):
|
||||||
def __init__(self, message, code=400):
|
def __init__(self, message, code=400):
|
||||||
super().__init__(message)
|
super().__init__(message)
|
||||||
|
self.type = "admin"
|
||||||
self.code = code
|
self.code = code
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
|
|
||||||
class UserNotFoundError(AdminException):
|
class UserNotFoundError(AdminException):
|
||||||
def __init__(self, username):
|
def __init__(self, username):
|
||||||
super().__init__(f"User '{username}' not found", 404)
|
super().__init__(f"User '{username}' not found", 404)
|
||||||
|
|
||||||
|
|
||||||
class UserAlreadyExistsError(AdminException):
|
class UserAlreadyExistsError(AdminException):
|
||||||
def __init__(self, username):
|
def __init__(self, username):
|
||||||
super().__init__(f"User '{username}' already exists", 409)
|
super().__init__(f"User '{username}' already exists", 409)
|
||||||
|
|
||||||
|
|
||||||
class CannotDeleteAdminError(AdminException):
|
class CannotDeleteAdminError(AdminException):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("Cannot delete admin account", 403)
|
super().__init__("Cannot delete admin account", 403)
|
||||||
Loading…
x
Reference in New Issue
Block a user