MaxKB/apps/common/exception/app_exception.py
2023-09-15 17:40:35 +08:00

43 lines
846 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding=utf-8
"""
@project: qabot
@Author
@file app_exception.py
@date2023/9/4 14:04
@desc:
"""
from rest_framework import status
class AppApiException(Exception):
"""
项目内异常
"""
status_code = status.HTTP_200_OK
def __init__(self, code, message):
self.code = code
self.message = message
class AppAuthenticationFailed(AppApiException):
"""
未认证(未登录)异常
"""
status_code = status.HTTP_401_UNAUTHORIZED
def __init__(self, code, message):
self.code = code
self.message = message
class AppUnauthorizedFailed(AppApiException):
"""
未授权(没有权限)异常
"""
status_code = status.HTTP_403_FORBIDDEN
def __init__(self, code, message):
self.code = code
self.message = message