-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherrors.py
More file actions
40 lines (25 loc) · 1004 Bytes
/
errors.py
File metadata and controls
40 lines (25 loc) · 1004 Bytes
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
import json
class ClientError(Exception):
"""Base class for all Client errors."""
def __init__(self, message: str | None = None):
super().__init__(message or self.MESSAGE)
class NotLoggedIn(ClientError):
MESSAGE = (
"You are not logged in yet. \n"
"You have to call client.login(email, password) first or provide API token with use_token()."
)
class TenantNotSelected(ClientError):
MESSAGE = (
"You have to select a Tenant (Environment) with client.use_tenant(tenant) first"
"or provide API token with use_token()."
)
class InvalidCABundle(ClientError):
MESSAGE = "The CA bundle is invalid or doesn't exist."
class InvalidAPIToken(ClientError):
MESSAGE = "The API Token is invalid."
class QueryError(ClientError):
"""raised when a GraphQL query returns errors."""
def __init__(self, errors_json: dict):
self.errors = errors_json
def __str__(self):
return json.dumps(self.errors, indent=4)