-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
97 lines (59 loc) · 2.22 KB
/
Copy pathexceptions.py
File metadata and controls
97 lines (59 loc) · 2.22 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from __future__ import annotations
from typing import Optional, Any
class CodeVFError(Exception):
"""Base exception for all CodeVF SDK errors."""
pass
class APIConnectionError(CodeVFError):
"""Raised when communication with the API fails (network issues)."""
pass
class APIError(CodeVFError):
"""Raised when the API returns a non-success status code."""
def __init__(self, message: str, status_code: Optional[int] = None, body: Any = None):
super().__init__(message)
self.status_code = status_code
self.body = body
class AuthenticationError(APIError):
"""Raised when API Key is invalid or missing (401/403)."""
pass
class NotFoundError(APIError):
"""Raised when a resource is not found (404)."""
pass
class RateLimitError(APIError):
"""Raised when API rate limit is exceeded (429)."""
pass
class ServerError(APIError):
"""Raised when the API encounters an internal error (5xx)."""
pass
class BadRequestError(APIError):
"""Raised when the server rejects a request with HTTP 400."""
pass
class InvalidModeError(APIError):
"""Raised when the provided mode is invalid."""
pass
class InvalidTagError(APIError):
"""Raised when the provided tagId is unknown or inactive."""
pass
class InvalidMetadataError(APIError):
"""Raised when metadata contains disallowed keys or nested values."""
pass
class MaxCreditsExceededError(APIError):
"""Raised when the maxCredits field is insufficient after multipliers."""
pass
class AttachmentLimitExceededError(APIError):
"""Raised when more than five attachments are submitted."""
pass
class AttachmentTooLargeError(APIError):
"""Raised when an attachment exceeds the supported size limits."""
pass
class IdempotencyConflictError(APIError):
"""Raised when an idempotency key is re-used by a different API key."""
pass
class InsufficientCreditsError(APIError):
"""Raised when the account lacks enough credits for the requested task."""
pass
class InvalidSchemaError(APIError):
"""Raised when the provided responseSchema is invalid JSON Schema."""
pass
class PayloadTooLargeError(APIError):
"""Raised when the JSON body exceeds 150KB."""
pass