exceptions.py
1.02 KB
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
"""自定义异常模块."""
class EmbeddingServiceError(Exception):
"""Embedding服务基础异常."""
def __init__(self, message: str, code: str = "EMBEDDING_ERROR"):
self.message = message
self.code = code
super().__init__(self.message)
class EmbeddingAPIError(EmbeddingServiceError):
"""Embedding API调用异常."""
def __init__(self, message: str, status_code: int = 500):
super().__init__(message, code="EMBEDDING_API_ERROR")
self.status_code = status_code
class DatabaseError(EmbeddingServiceError):
"""数据库操作异常."""
def __init__(self, message: str):
super().__init__(message, code="DATABASE_ERROR")
class NotFoundError(EmbeddingServiceError):
"""资源不存在异常."""
def __init__(self, message: str):
super().__init__(message, code="NOT_FOUND")
class ValidationError(EmbeddingServiceError):
"""参数校验异常."""
def __init__(self, message: str):
super().__init__(message, code="VALIDATION_ERROR")