1 # -*- coding: utf-8 -*-
4 class ViewCacheNoDataException(Exception):
7 super(ViewCacheNoDataException
, self
).__init
__('ViewCache: unable to retrieve data')
10 class DashboardException(Exception):
12 Used for exceptions that are already handled and should end up as a user error.
13 Or, as a replacement for cherrypy.HTTPError(...)
15 Typically, you don't inherent from DashboardException
18 # pylint: disable=too-many-arguments
19 def __init__(self
, e
=None, code
=None, component
=None, http_status_code
=None, msg
=None):
20 super(DashboardException
, self
).__init
__(msg
)
22 self
.component
= component
26 self
.status
= http_status_code
33 except AttributeError:
34 return super(DashboardException
, self
).__str
__()
43 return str(self
._code
)
44 return str(abs(self
.errno
)) if self
.errno
is not None else 'Error'
47 class InvalidCredentialsError(DashboardException
):
49 super().__init
__(msg
='Invalid credentials',
50 code
='invalid_credentials',
54 # access control module exceptions
55 class RoleAlreadyExists(Exception):
56 def __init__(self
, name
):
57 super(RoleAlreadyExists
, self
).__init
__(
58 "Role '{}' already exists".format(name
))
61 class RoleDoesNotExist(Exception):
62 def __init__(self
, name
):
63 super(RoleDoesNotExist
, self
).__init
__(
64 "Role '{}' does not exist".format(name
))
67 class ScopeNotValid(Exception):
68 def __init__(self
, name
):
69 super(ScopeNotValid
, self
).__init
__(
70 "Scope '{}' is not valid".format(name
))
73 class PermissionNotValid(Exception):
74 def __init__(self
, name
):
75 super(PermissionNotValid
, self
).__init
__(
76 "Permission '{}' is not valid".format(name
))
79 class RoleIsAssociatedWithUser(Exception):
80 def __init__(self
, rolename
, username
):
81 super(RoleIsAssociatedWithUser
, self
).__init
__(
82 "Role '{}' is still associated with user '{}'"
83 .format(rolename
, username
))
86 class UserAlreadyExists(Exception):
87 def __init__(self
, name
):
88 super(UserAlreadyExists
, self
).__init
__(
89 "User '{}' already exists".format(name
))
92 class UserDoesNotExist(Exception):
93 def __init__(self
, name
):
94 super(UserDoesNotExist
, self
).__init
__(
95 "User '{}' does not exist".format(name
))
98 class ScopeNotInRole(Exception):
99 def __init__(self
, scopename
, rolename
):
100 super(ScopeNotInRole
, self
).__init
__(
101 "There are no permissions for scope '{}' in role '{}'"
102 .format(scopename
, rolename
))
105 class RoleNotInUser(Exception):
106 def __init__(self
, rolename
, username
):
107 super(RoleNotInUser
, self
).__init
__(
108 "Role '{}' is not associated with user '{}'"
109 .format(rolename
, username
))
112 class PwdExpirationDateNotValid(Exception):
114 super(PwdExpirationDateNotValid
, self
).__init
__(
115 "The password expiration date must not be in the past")
118 class GrafanaError(Exception):
122 class PasswordPolicyException(Exception):