-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.py
More file actions
59 lines (40 loc) · 1.21 KB
/
Copy patherrors.py
File metadata and controls
59 lines (40 loc) · 1.21 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from __future__ import annotations
from typing import Any
class ApplicationError(Exception):
"""应用层基础异常。"""
status_code = 500
code = "application_error"
def __init__(
self,
detail: str,
*,
code: str | None = None,
status_code: int | None = None,
extra: dict[str, Any] | None = None,
) -> None:
super().__init__(detail)
self.detail = detail
self.code = code or self.code
self.status_code = status_code or self.status_code
self.extra = extra or {}
class NotFoundError(ApplicationError):
status_code = 404
code = "not_found"
class ContractError(ApplicationError):
status_code = 400
code = "contract_error"
class AuthError(ApplicationError):
status_code = 401
code = "auth_error"
class PersistenceError(ApplicationError):
status_code = 500
code = "persistence_error"
class ReportGenerationError(ApplicationError):
status_code = 500
code = "report_generation_error"
class RuntimeConflictError(ApplicationError):
status_code = 409
code = "runtime_conflict"
class ConfigurationError(ApplicationError):
status_code = 500
code = "configuration_error"