-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy patherrors.py
More file actions
61 lines (35 loc) · 1.41 KB
/
errors.py
File metadata and controls
61 lines (35 loc) · 1.41 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
"""JMAP error types as per RFC 8620."""
class JMAPError(Exception):
"""Base JMAP error."""
error_type: str = "serverFail"
def __init__(self, description: str = ""):
self.description = description
super().__init__(description)
def to_response(self, call_id: str) -> list:
"""Convert to JMAP error response tuple."""
return [
"error",
{"type": self.error_type, "description": self.description},
call_id,
]
class UnknownCapabilityError(JMAPError):
"""The request used a capability not advertised in the session."""
error_type = "unknownCapability"
class UnknownMethodError(JMAPError):
"""The method name is not recognized."""
error_type = "unknownMethod"
class InvalidArgumentsError(JMAPError):
"""One or more arguments are of the wrong type or invalid."""
error_type = "invalidArguments"
class InvalidResultReferenceError(JMAPError):
"""A result reference could not be resolved."""
error_type = "invalidResultReference"
class AccountNotFoundError(JMAPError):
"""The accountId does not correspond to a valid account."""
error_type = "accountNotFound"
class ForbiddenError(JMAPError):
"""The action is forbidden for the authenticated user."""
error_type = "forbidden"
class ServerFailError(JMAPError):
"""An unexpected server error occurred."""
error_type = "serverFail"