forked from yokonsan/midjourney-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exceptions.py
51 lines (32 loc) · 1.04 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from enum import Enum
from typing import Union
class ErrorCode(Enum):
MISS_REQUIRED_VARIABLE_ERROR = 11
MAX_RETRY_ERROR = 12
REQUEST_PARAMS_ERROR = 13
BANNED_PROMPT_ERROR = 14
QUEUE_FULL_ERROR = 15
class SuccessCode(Enum):
SUCCESS = 0
ReturnCode = Union[ErrorCode, SuccessCode]
class APPBaseException(Exception):
code: ErrorCode
message: str
def __init__(self, message: str):
super().__init__(message)
self.message = message
class MissRequiredVariableError(APPBaseException):
"""缺少必需变量"""
code = ErrorCode.MISS_REQUIRED_VARIABLE_ERROR
class MaxRetryError(APPBaseException):
"""请求最大重试错误"""
code = ErrorCode.MAX_RETRY_ERROR
class RequestParamsError(APPBaseException):
"""请求参数异常"""
code = ErrorCode.REQUEST_PARAMS_ERROR
class BannedPromptError(APPBaseException):
"""提示词被禁用"""
code = ErrorCode.BANNED_PROMPT_ERROR
class QueueFullError(APPBaseException):
"""队列已满"""
code = ErrorCode.QUEUE_FULL_ERROR