flashdata 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
flashdata/errors.py ADDED
@@ -0,0 +1,69 @@
1
+ """Public exceptions. Request bodies, keys and signed URLs are never in reprs."""
2
+
3
+ from typing import Any
4
+
5
+
6
+ class FlashDataError(Exception):
7
+ """Base SDK exception."""
8
+
9
+
10
+ class ValidationError(FlashDataError, ValueError):
11
+ """An input is invalid; no HTTP request was sent."""
12
+
13
+
14
+ class APIError(FlashDataError):
15
+ """A non-success response from FlashData or signed storage."""
16
+
17
+ def __init__(
18
+ self,
19
+ status_code: int,
20
+ message: str,
21
+ *,
22
+ code: str | None = None,
23
+ request_id: str | None = None,
24
+ retry_after: str | None = None,
25
+ body: Any = None,
26
+ ):
27
+ super().__init__(message)
28
+ self.status_code = status_code
29
+ self.code = code
30
+ self.request_id = request_id
31
+ self.retry_after = retry_after
32
+ self.body = body
33
+ self.field_errors = body.get("fieldErrors", []) if isinstance(body, dict) else []
34
+
35
+
36
+ class ConnectionError(FlashDataError):
37
+ """The network request failed."""
38
+
39
+
40
+ class RequestTimeoutError(ConnectionError):
41
+ """A read request exceeded its network timeout."""
42
+
43
+
44
+ class SubmissionUnknownError(ConnectionError):
45
+ """A mutation lost its response and may already have taken effect."""
46
+
47
+
48
+ class ProtocolError(FlashDataError):
49
+ """An unexpected response, redirect or result origin was rejected."""
50
+
51
+
52
+ class ResponseTooLargeError(ProtocolError):
53
+ """The configured response or decompressed-line limit was exceeded."""
54
+
55
+
56
+ class PollingTimeoutError(FlashDataError):
57
+ def __init__(self, job_id: str):
58
+ super().__init__(f"Waiting for {job_id} timed out; continue reading the same ID.")
59
+ self.job_id = job_id
60
+
61
+
62
+ class JobFailedError(FlashDataError):
63
+ def __init__(self, job: dict[str, Any]):
64
+ super().__init__(f"Job {job.get('id', 'unknown')} ended with status {job.get('status')}.")
65
+ self.job = job
66
+
67
+
68
+ class JobPausedError(JobFailedError):
69
+ """A bulk job is paused and needs explicit user action."""
flashdata/py.typed ADDED
File without changes