/
exceptions.py
executable file
·86 lines (61 loc) · 2.15 KB
/
exceptions.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import json
from webapp.apps.exceptions import CSException, CSError
class AppError(CSError):
def __init__(self, parameters, traceback):
self.parameters = json.dumps(parameters, indent=4)
self.traceback = traceback
super().__init__(traceback)
class ValidationError(CSError):
pass
class BadPostException(CSError):
def __init__(self, errors, *args, **kwargs):
self.errors = errors
super().__init__(*args, **kwargs)
class ForkObjectException(CSError):
pass
class VersionMismatchException(CSError):
pass
class PermissionExpiredException(CSError):
pass
class PrivateSimException(CSException):
msg = (
"You have reached the limit for the number of private simulations "
"for this month. You can upgrade to Compute Studio Pro to have an "
"unlimited number of private simulations."
)
resource = "simulation"
def __init__(self, *args):
msg = args[0] if args else self.msg
super().__init__(msg)
def todict(self):
return dict(
resource=self.resource,
test_name="make_simulation_private",
upgrade_to="pro",
msg=str(self),
)
class PrivateAppException(CSException):
msg = (
"This user does not have access to this app. You must grant access"
"for them to use the app before you can add them as a collaborator."
)
resource = "collaborator"
def __init__(self, collaborator, *args, **kwargs):
self.collaborator = collaborator
msg = args[0] if args else self.msg
super().__init__(msg)
def todict(self):
return dict(
resource=self.resource,
test_name="add_collaborator_on_private_app",
collaborator=getattr(self.collaborator, "username", str(self.collaborator)),
msg=str(self),
)
class NotReady(CSException):
def __init__(self, instance, *args, **kwargs):
self.instance = instance
super().__init__(*args, **kwargs)
class Stale(CSException):
def __init__(self, instance, *args, **kwargs):
self.instance = instance
super().__init__(*args, **kwargs)