1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2025-11-21 13:19:16 +01:00

Added documentation on the lodel/auth/exceptions.py module

This commit is contained in:
Roland Haroutiounian 2017-03-22 11:51:09 +01:00
commit 5d43f04276

View file

@ -1,24 +1,30 @@
# @package lodel.auth.exceptions
# @brief Defines the specific exceptions used in the authentication process
from lodel.context import LodelContext
LodelContext.expose_modules(globals(), {
'lodel.logger': 'logger',
'lodel.plugin.hooks': ['LodelHook']})
##@brief Handles common errors with a Client
## @brief Handles common errors with a Client
class ClientError(Exception):
##@brief The logger function to use to log the error message
## @brief The logger function to use to log the error message
_loglvl = 'warning'
##@brief Error str
## @brief Error string
_err_str = "Error"
##@brief the hook name to trigger with error
## @brief the hook name to trigger with error
_action = 'lodel2_ui_error'
##@brief the hook payload
## @brief the hook payload
_payload = None
##@brief Constructor
## @brief Constructor
#
#Log message are build using the following format :
#"<client infos> : <_err_str>[ : <msg>]"
# Log messages are built using the following format :
# "<client infos> : <_err_str>[ : <msg>]"
# @param client Client : object containing the client's data
# @param msg str : message string to use
def __init__(self, client, msg = ""):
msg = self.build_message(client, msg)
if self._loglvl is not None:
@ -28,30 +34,41 @@ class ClientError(Exception):
if self._action is not None:
LodelHook.call_hook(self._action, self, self._payload)
##@brief build error message
## @brief Builds an error message
# @param client Client
# @param msg str
def build_message(self, client, msg):
res = "%s : %s" % (client, self._err_str)
if len(msg) > 0:
res += " : %s" % msg
return res
##@brief Handles authentication failure errors
## @brief Handles authentication failure errors
class ClientAuthenticationFailure(ClientError):
## @brief Log Level
_loglvl = 'security'
## @brief Error string
_err_str = 'Authentication failure'
## @brief Hook to trigger
_action = 'lodel2_ui_authentication_failure'
##@brief Handles permission denied errors
class ClientPermissionDenied(ClientError):
## @brief Log level
_loglvl = 'security'
## @brief Error string
_err_str = 'Permission denied'
## @brief Hook to trigger
_action = 'lodel2_ui_permission_denied'
##@brief Handles common errors on authentication
class ClientAuthenticationError(ClientError):
## @brief Log level
_loglvl = 'error'
## @brief Error string
_err_str = 'Authentication error'
## @brief Hook to trigger
_action = 'lodel2_ui_error'