forked from pulp/pulp-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
67 lines (41 loc) · 2 KB
/
exceptions.py
File metadata and controls
67 lines (41 loc) · 2 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
from pulp_glue.common.i18n import get_translation
translation = get_translation(__package__)
_ = translation.gettext
class PulpException(Exception):
"""The base exception `pulp-glue` will emit on expected error paths."""
class PulpEntityNotFound(PulpException):
"""Exception to signify that an entity was not found."""
class PulpHTTPError(PulpException):
"""Exception to indicate HTTP error responses."""
def __init__(self, msg: str, status_code: int, operation_id: str | None = None) -> None:
super().__init__(msg)
self.status_code = status_code
self.operation_id = operation_id
class PulpAuthenticationFailed(PulpHTTPError):
"""Exception to signal a failed authentication."""
def __init__(self, operation_id: str) -> None:
super().__init__(
_("Authentication failed for {operation_id}.").format(operation_id=operation_id),
401,
operation_id,
)
class PulpNotAutorized(PulpHTTPError):
"""Exception to signal an action was not autorized."""
def __init__(self, operation_id: str) -> None:
super().__init__(
_("Operation {operation_id} is not authorized.").format(operation_id=operation_id),
403,
operation_id,
)
class PulpNoWait(Exception):
"""Exception to indicate that a task continues running in the background."""
class NotImplementedFake(NotImplementedError, PulpException):
"""Exception to indicat that a call without a fake version was attempted in fake_mode."""
class OpenAPIError(PulpException):
"""Base Exception for errors related to using the openapi spec."""
class ValidationError(OpenAPIError):
"""Exception raised for failed client side validation of parameters or request bodies."""
class SchemaError(OpenAPIError):
"""Exception raised for unsurmountable inconsistencies of the openapi schema."""
class UnsafeCallError(OpenAPIError):
"""Exception raised for POST, PUT, PATCH or DELETE calls with `safe_calls_only=True`."""