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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# -*- coding: utf-8 -*-
class ViewCacheNoDataException(Exception):
def __init__(self):
self.status = 200
super(ViewCacheNoDataException, self).__init__('ViewCache: unable to retrieve data')
class DashboardException(Exception):
"""
Used for exceptions that are already handled and should end up as a user error.
Or, as a replacement for cherrypy.HTTPError(...)
Typically, you don't inherent from DashboardException
"""
# pylint: disable=too-many-arguments
def __init__(self, e=None, code=None, component=None, http_status_code=None, msg=None):
super(DashboardException, self).__init__(msg)
self._code = code
self.component = component
if e:
self.e = e
if http_status_code:
self.status = http_status_code
else:
self.status = 400
def __str__(self):
try:
return str(self.e)
except AttributeError:
return super(DashboardException, self).__str__()
@property
def errno(self):
return self.e.errno
@property
def code(self):
if self._code:
return str(self._code)
return str(abs(self.errno)) if self.errno is not None else 'Error'
class InvalidCredentialsError(DashboardException):
def __init__(self):
super().__init__(msg='Invalid credentials',
code='invalid_credentials',
component='auth')
# access control module exceptions
class RoleAlreadyExists(Exception):
def __init__(self, name):
super(RoleAlreadyExists, self).__init__(
"Role '{}' already exists".format(name))
class RoleDoesNotExist(Exception):
def __init__(self, name):
super(RoleDoesNotExist, self).__init__(
"Role '{}' does not exist".format(name))
class ScopeNotValid(Exception):
def __init__(self, name):
super(ScopeNotValid, self).__init__(
"Scope '{}' is not valid".format(name))
class PermissionNotValid(Exception):
def __init__(self, name):
super(PermissionNotValid, self).__init__(
"Permission '{}' is not valid".format(name))
class RoleIsAssociatedWithUser(Exception):
def __init__(self, rolename, username):
super(RoleIsAssociatedWithUser, self).__init__(
"Role '{}' is still associated with user '{}'"
.format(rolename, username))
class UserAlreadyExists(Exception):
def __init__(self, name):
super(UserAlreadyExists, self).__init__(
"User '{}' already exists".format(name))
class UserDoesNotExist(Exception):
def __init__(self, name):
super(UserDoesNotExist, self).__init__(
"User '{}' does not exist".format(name))
class ScopeNotInRole(Exception):
def __init__(self, scopename, rolename):
super(ScopeNotInRole, self).__init__(
"There are no permissions for scope '{}' in role '{}'"
.format(scopename, rolename))
class RoleNotInUser(Exception):
def __init__(self, rolename, username):
super(RoleNotInUser, self).__init__(
"Role '{}' is not associated with user '{}'"
.format(rolename, username))
class PwdExpirationDateNotValid(Exception):
def __init__(self):
super(PwdExpirationDateNotValid, self).__init__(
"The password expiration date must not be in the past")
class GrafanaError(Exception):
pass
class PasswordPolicyException(Exception):
pass
class ExpiredSignatureError(Exception):
pass
class InvalidTokenError(Exception):
pass
class InvalidAlgorithmError(Exception):
pass
|