1 # -*- coding: utf-8 -*-
2 from __future__
import absolute_import
5 class ViewCacheNoDataException(Exception):
8 super(ViewCacheNoDataException
, self
).__init
__('ViewCache: unable to retrieve data')
11 class DashboardException(Exception):
13 Used for exceptions that are already handled and should end up as a user error.
14 Or, as a replacement for cherrypy.HTTPError(...)
16 Typically, you don't inherent from DashboardException
19 # pylint: disable=too-many-arguments
20 def __init__(self
, e
=None, code
=None, component
=None, http_status_code
=None, msg
=None):
21 super(DashboardException
, self
).__init
__(msg
)
23 self
.component
= component
27 self
.status
= http_status_code
34 except AttributeError:
35 return super(DashboardException
, self
).__str
__()
44 return str(self
._code
)
45 return str(abs(self
.errno
)) if self
.errno
is not None else 'Error'
48 # access control module exceptions
49 class RoleAlreadyExists(Exception):
50 def __init__(self
, name
):
51 super(RoleAlreadyExists
, self
).__init
__(
52 "Role '{}' already exists".format(name
))
55 class RoleDoesNotExist(Exception):
56 def __init__(self
, name
):
57 super(RoleDoesNotExist
, self
).__init
__(
58 "Role '{}' does not exist".format(name
))
61 class ScopeNotValid(Exception):
62 def __init__(self
, name
):
63 super(ScopeNotValid
, self
).__init
__(
64 "Scope '{}' is not valid".format(name
))
67 class PermissionNotValid(Exception):
68 def __init__(self
, name
):
69 super(PermissionNotValid
, self
).__init
__(
70 "Permission '{}' is not valid".format(name
))
73 class RoleIsAssociatedWithUser(Exception):
74 def __init__(self
, rolename
, username
):
75 super(RoleIsAssociatedWithUser
, self
).__init
__(
76 "Role '{}' is still associated with user '{}'"
77 .format(rolename
, username
))
80 class UserAlreadyExists(Exception):
81 def __init__(self
, name
):
82 super(UserAlreadyExists
, self
).__init
__(
83 "User '{}' already exists".format(name
))
86 class UserDoesNotExist(Exception):
87 def __init__(self
, name
):
88 super(UserDoesNotExist
, self
).__init
__(
89 "User '{}' does not exist".format(name
))
92 class ScopeNotInRole(Exception):
93 def __init__(self
, scopename
, rolename
):
94 super(ScopeNotInRole
, self
).__init
__(
95 "There are no permissions for scope '{}' in role '{}'"
96 .format(scopename
, rolename
))
99 class RoleNotInUser(Exception):
100 def __init__(self
, rolename
, username
):
101 super(RoleNotInUser
, self
).__init
__(
102 "Role '{}' is not associated with user '{}'"
103 .format(rolename
, username
))
106 class PwdExpirationDateNotValid(Exception):
108 super(PwdExpirationDateNotValid
, self
).__init
__(
109 "The password expiration date must not be in the past")
112 class GrafanaError(Exception):
116 class PasswordPolicyException(Exception):