-
Notifications
You must be signed in to change notification settings - Fork 797
Expand file tree
/
Copy patherrors.py
More file actions
59 lines (35 loc) · 1.5 KB
/
errors.py
File metadata and controls
59 lines (35 loc) · 1.5 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
#!/usr/bin/env python
"""API errors definitions."""
VersionTuple = tuple[int, int, int, int]
class Error(RuntimeError):
"""Errors generated by API client library."""
class ResourceNotFoundError(Error):
"""Raised when resource is not found."""
class AccessForbiddenError(Error):
"""Raised when resource access is forbidden."""
# Conceptually ResourceExhaustedError is still an AccessForbiddenError, as
# it means that the access to resource was forbidden due to the lack of quota.
class ResourceExhaustedError(AccessForbiddenError):
"""Raised when resource can't be accessed due to exhausted quota."""
class ApiNotImplementedError(Error):
"""Raised when API method is not implemented."""
class UnknownError(Error):
"""Unknown server error."""
class PollTimeoutError(Error):
"""Raised when poll operations times out."""
class FlowFailedError(Error):
"""Raised when waiting on a flow that eventually fails."""
class InvalidArgumentError(Error):
"""Raised when invalid argument(s) is/are passed to the API call."""
class VersionMismatchError(Error):
"""Raised when API client version is incompatible with the server."""
def __init__(
self,
server_version: VersionTuple,
api_client_version: VersionTuple,
):
message = "GRR server is {server}, but API client is only {client}"
message = message.format(server=server_version, client=api_client_version)
super().__init__(message)
self.server_version = server_version
self.api_client_version = api_client_version