Exceptions¶
pyecotrend_ista.exception_classes ¶
Exception Class.
Classes:
-
BaseError–Base class for exceptions in this module.
-
ServerError–Exception raised for server errors during requests.
-
LoginError–Exception raised for login- and authentication related errors.
-
ParserError–Exception raised for errors encountered during parsing.
-
KeycloakError–Base class for custom Keycloak errors.
-
KeycloakAuthenticationError–Keycloak authentication error exception.
-
KeycloakOperationError–Keycloak operation error exception.
-
KeycloakGetError–Keycloak request get error exception.
-
KeycloakPostError–Keycloak request post error exception.
-
KeycloakCodeNotFound–Keycloak Code not found exception.
-
KeycloakInvalidTokenError–Keycloak invalid token exception.
Functions:
-
deprecated–Decorate a function as deprecated and emit a warning when called.
BaseError ¶
flowchart TD
pyecotrend_ista.exception_classes.BaseError[BaseError]
click pyecotrend_ista.exception_classes.BaseError href "" "pyecotrend_ista.exception_classes.BaseError"
Base class for exceptions in this module.
This is the base class for all custom exceptions in the module. It inherits from Python's built-in Exception class and can be used to catch errors specific to this module.
ServerError ¶
flowchart TD
pyecotrend_ista.exception_classes.ServerError[ServerError]
pyecotrend_ista.exception_classes.BaseError[BaseError]
pyecotrend_ista.exception_classes.BaseError --> pyecotrend_ista.exception_classes.ServerError
click pyecotrend_ista.exception_classes.ServerError href "" "pyecotrend_ista.exception_classes.ServerError"
click pyecotrend_ista.exception_classes.BaseError href "" "pyecotrend_ista.exception_classes.BaseError"
Exception raised for server errors during requests.
This exception is raised when a exception occurs during a request. It inherits from BaseError and can be used to handle server-related issues specifically.
Methods:
-
__str__–Return a string representation of the error..
LoginError ¶
flowchart TD
pyecotrend_ista.exception_classes.LoginError[LoginError]
pyecotrend_ista.exception_classes.BaseError[BaseError]
pyecotrend_ista.exception_classes.BaseError --> pyecotrend_ista.exception_classes.LoginError
click pyecotrend_ista.exception_classes.LoginError href "" "pyecotrend_ista.exception_classes.LoginError"
click pyecotrend_ista.exception_classes.BaseError href "" "pyecotrend_ista.exception_classes.BaseError"
Exception raised for login- and authentication related errors.
This exception is raised when an authentication exception occurs during a request. It inherits from BaseError and is used specifically to handle issues related to authentication and login.
Methods:
-
__str__–Return a string representation of an authentication error.
ParserError ¶
flowchart TD
pyecotrend_ista.exception_classes.ParserError[ParserError]
pyecotrend_ista.exception_classes.ServerError[ServerError]
pyecotrend_ista.exception_classes.BaseError[BaseError]
pyecotrend_ista.exception_classes.ServerError --> pyecotrend_ista.exception_classes.ParserError
pyecotrend_ista.exception_classes.BaseError --> pyecotrend_ista.exception_classes.ServerError
click pyecotrend_ista.exception_classes.ParserError href "" "pyecotrend_ista.exception_classes.ParserError"
click pyecotrend_ista.exception_classes.ServerError href "" "pyecotrend_ista.exception_classes.ServerError"
click pyecotrend_ista.exception_classes.BaseError href "" "pyecotrend_ista.exception_classes.BaseError"
Exception raised for errors encountered during parsing.
This exception is raised when an error occurs during the parsing process of the request response. It inherits from BaseError and can be used to handle issues specifically related to parsing.
Methods:
-
__str__–Return a string representation of parser error.
KeycloakError ¶
KeycloakError(error_message='', response_code=None, response_body=None)
flowchart TD
pyecotrend_ista.exception_classes.KeycloakError[KeycloakError]
click pyecotrend_ista.exception_classes.KeycloakError href "" "pyecotrend_ista.exception_classes.KeycloakError"
Base class for custom Keycloak errors.
Parameters:
-
(error_message¶str, default:'') –The error message (default is an empty string).
-
(response_code¶int, default:None) –The code of the response (default is None).
-
(response_body¶bytes, default:None) –Body of the response (default is None).
Methods:
-
__str__–Str method.
Source code in src/pyecotrend_ista/exception_classes.py
def __init__(self, error_message="", response_code=None, response_body=None): # numpydoc ignore=ES01,EX01
"""Init method.
Parameters
----------
error_message : str, optional
The error message (default is an empty string).
response_code : int, optional
The code of the response (default is None).
response_body : bytes, optional
Body of the response (default is None).
"""
Exception.__init__(self, error_message)
self.response_code = response_code
self.response_body = response_body
self.error_message = error_message __str__ ¶
__str__() Str method.
Returns:
-
str–String representation of the object.
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self):
"""Str method.
Returns
-------
str
String representation of the object.
"""
if self.response_code is not None:
return f"{self.response_code}: {self.error_message}"
return f"{self.error_message}" KeycloakAuthenticationError ¶
KeycloakAuthenticationError(error_message='', response_code=None, response_body=None)
flowchart TD
pyecotrend_ista.exception_classes.KeycloakAuthenticationError[KeycloakAuthenticationError]
pyecotrend_ista.exception_classes.KeycloakError[KeycloakError]
pyecotrend_ista.exception_classes.KeycloakError --> pyecotrend_ista.exception_classes.KeycloakAuthenticationError
click pyecotrend_ista.exception_classes.KeycloakAuthenticationError href "" "pyecotrend_ista.exception_classes.KeycloakAuthenticationError"
click pyecotrend_ista.exception_classes.KeycloakError href "" "pyecotrend_ista.exception_classes.KeycloakError"
Keycloak authentication error exception.
Parameters:
-
(error_message¶str, default:'') –The error message (default is an empty string).
-
(response_code¶int, default:None) –The code of the response (default is None).
-
(response_body¶bytes, default:None) –Body of the response (default is None).
Methods:
-
__str__–Str method.
Source code in src/pyecotrend_ista/exception_classes.py
def __init__(self, error_message="", response_code=None, response_body=None): # numpydoc ignore=ES01,EX01
"""Init method.
Parameters
----------
error_message : str, optional
The error message (default is an empty string).
response_code : int, optional
The code of the response (default is None).
response_body : bytes, optional
Body of the response (default is None).
"""
Exception.__init__(self, error_message)
self.response_code = response_code
self.response_body = response_body
self.error_message = error_message __str__ ¶
__str__() Str method.
Returns:
-
str–String representation of the object.
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self):
"""Str method.
Returns
-------
str
String representation of the object.
"""
if self.response_code is not None:
return f"{self.response_code}: {self.error_message}"
return f"{self.error_message}" KeycloakOperationError ¶
KeycloakOperationError(error_message='', response_code=None, response_body=None)
flowchart TD
pyecotrend_ista.exception_classes.KeycloakOperationError[KeycloakOperationError]
pyecotrend_ista.exception_classes.KeycloakError[KeycloakError]
pyecotrend_ista.exception_classes.KeycloakError --> pyecotrend_ista.exception_classes.KeycloakOperationError
click pyecotrend_ista.exception_classes.KeycloakOperationError href "" "pyecotrend_ista.exception_classes.KeycloakOperationError"
click pyecotrend_ista.exception_classes.KeycloakError href "" "pyecotrend_ista.exception_classes.KeycloakError"
Keycloak operation error exception.
Parameters:
-
(error_message¶str, default:'') –The error message (default is an empty string).
-
(response_code¶int, default:None) –The code of the response (default is None).
-
(response_body¶bytes, default:None) –Body of the response (default is None).
Methods:
-
__str__–Str method.
Source code in src/pyecotrend_ista/exception_classes.py
def __init__(self, error_message="", response_code=None, response_body=None): # numpydoc ignore=ES01,EX01
"""Init method.
Parameters
----------
error_message : str, optional
The error message (default is an empty string).
response_code : int, optional
The code of the response (default is None).
response_body : bytes, optional
Body of the response (default is None).
"""
Exception.__init__(self, error_message)
self.response_code = response_code
self.response_body = response_body
self.error_message = error_message __str__ ¶
__str__() Str method.
Returns:
-
str–String representation of the object.
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self):
"""Str method.
Returns
-------
str
String representation of the object.
"""
if self.response_code is not None:
return f"{self.response_code}: {self.error_message}"
return f"{self.error_message}" KeycloakGetError ¶
KeycloakGetError(error_message='', response_code=None, response_body=None)
flowchart TD
pyecotrend_ista.exception_classes.KeycloakGetError[KeycloakGetError]
pyecotrend_ista.exception_classes.KeycloakOperationError[KeycloakOperationError]
pyecotrend_ista.exception_classes.KeycloakError[KeycloakError]
pyecotrend_ista.exception_classes.KeycloakOperationError --> pyecotrend_ista.exception_classes.KeycloakGetError
pyecotrend_ista.exception_classes.KeycloakError --> pyecotrend_ista.exception_classes.KeycloakOperationError
click pyecotrend_ista.exception_classes.KeycloakGetError href "" "pyecotrend_ista.exception_classes.KeycloakGetError"
click pyecotrend_ista.exception_classes.KeycloakOperationError href "" "pyecotrend_ista.exception_classes.KeycloakOperationError"
click pyecotrend_ista.exception_classes.KeycloakError href "" "pyecotrend_ista.exception_classes.KeycloakError"
Keycloak request get error exception.
Parameters:
-
(error_message¶str, default:'') –The error message (default is an empty string).
-
(response_code¶int, default:None) –The code of the response (default is None).
-
(response_body¶bytes, default:None) –Body of the response (default is None).
Methods:
-
__str__–Str method.
Source code in src/pyecotrend_ista/exception_classes.py
def __init__(self, error_message="", response_code=None, response_body=None): # numpydoc ignore=ES01,EX01
"""Init method.
Parameters
----------
error_message : str, optional
The error message (default is an empty string).
response_code : int, optional
The code of the response (default is None).
response_body : bytes, optional
Body of the response (default is None).
"""
Exception.__init__(self, error_message)
self.response_code = response_code
self.response_body = response_body
self.error_message = error_message __str__ ¶
__str__() Str method.
Returns:
-
str–String representation of the object.
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self):
"""Str method.
Returns
-------
str
String representation of the object.
"""
if self.response_code is not None:
return f"{self.response_code}: {self.error_message}"
return f"{self.error_message}" KeycloakPostError ¶
KeycloakPostError(error_message='', response_code=None, response_body=None)
flowchart TD
pyecotrend_ista.exception_classes.KeycloakPostError[KeycloakPostError]
pyecotrend_ista.exception_classes.KeycloakOperationError[KeycloakOperationError]
pyecotrend_ista.exception_classes.KeycloakError[KeycloakError]
pyecotrend_ista.exception_classes.KeycloakOperationError --> pyecotrend_ista.exception_classes.KeycloakPostError
pyecotrend_ista.exception_classes.KeycloakError --> pyecotrend_ista.exception_classes.KeycloakOperationError
click pyecotrend_ista.exception_classes.KeycloakPostError href "" "pyecotrend_ista.exception_classes.KeycloakPostError"
click pyecotrend_ista.exception_classes.KeycloakOperationError href "" "pyecotrend_ista.exception_classes.KeycloakOperationError"
click pyecotrend_ista.exception_classes.KeycloakError href "" "pyecotrend_ista.exception_classes.KeycloakError"
Keycloak request post error exception.
Parameters:
-
(error_message¶str, default:'') –The error message (default is an empty string).
-
(response_code¶int, default:None) –The code of the response (default is None).
-
(response_body¶bytes, default:None) –Body of the response (default is None).
Methods:
-
__str__–Str method.
Source code in src/pyecotrend_ista/exception_classes.py
def __init__(self, error_message="", response_code=None, response_body=None): # numpydoc ignore=ES01,EX01
"""Init method.
Parameters
----------
error_message : str, optional
The error message (default is an empty string).
response_code : int, optional
The code of the response (default is None).
response_body : bytes, optional
Body of the response (default is None).
"""
Exception.__init__(self, error_message)
self.response_code = response_code
self.response_body = response_body
self.error_message = error_message __str__ ¶
__str__() Str method.
Returns:
-
str–String representation of the object.
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self):
"""Str method.
Returns
-------
str
String representation of the object.
"""
if self.response_code is not None:
return f"{self.response_code}: {self.error_message}"
return f"{self.error_message}" KeycloakCodeNotFound ¶
KeycloakCodeNotFound(error_message='', response_code=None, response_body=None)
flowchart TD
pyecotrend_ista.exception_classes.KeycloakCodeNotFound[KeycloakCodeNotFound]
pyecotrend_ista.exception_classes.KeycloakOperationError[KeycloakOperationError]
pyecotrend_ista.exception_classes.KeycloakError[KeycloakError]
pyecotrend_ista.exception_classes.KeycloakOperationError --> pyecotrend_ista.exception_classes.KeycloakCodeNotFound
pyecotrend_ista.exception_classes.KeycloakError --> pyecotrend_ista.exception_classes.KeycloakOperationError
click pyecotrend_ista.exception_classes.KeycloakCodeNotFound href "" "pyecotrend_ista.exception_classes.KeycloakCodeNotFound"
click pyecotrend_ista.exception_classes.KeycloakOperationError href "" "pyecotrend_ista.exception_classes.KeycloakOperationError"
click pyecotrend_ista.exception_classes.KeycloakError href "" "pyecotrend_ista.exception_classes.KeycloakError"
Keycloak Code not found exception.
Parameters:
-
(error_message¶str, default:'') –The error message (default is an empty string).
-
(response_code¶int, default:None) –The code of the response (default is None).
-
(response_body¶bytes, default:None) –Body of the response (default is None).
Methods:
-
__str__–Str method.
Source code in src/pyecotrend_ista/exception_classes.py
def __init__(self, error_message="", response_code=None, response_body=None): # numpydoc ignore=ES01,EX01
"""Init method.
Parameters
----------
error_message : str, optional
The error message (default is an empty string).
response_code : int, optional
The code of the response (default is None).
response_body : bytes, optional
Body of the response (default is None).
"""
Exception.__init__(self, error_message)
self.response_code = response_code
self.response_body = response_body
self.error_message = error_message __str__ ¶
__str__() Str method.
Returns:
-
str–String representation of the object.
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self):
"""Str method.
Returns
-------
str
String representation of the object.
"""
if self.response_code is not None:
return f"{self.response_code}: {self.error_message}"
return f"{self.error_message}" KeycloakInvalidTokenError ¶
KeycloakInvalidTokenError(error_message='', response_code=None, response_body=None)
flowchart TD
pyecotrend_ista.exception_classes.KeycloakInvalidTokenError[KeycloakInvalidTokenError]
pyecotrend_ista.exception_classes.KeycloakOperationError[KeycloakOperationError]
pyecotrend_ista.exception_classes.KeycloakError[KeycloakError]
pyecotrend_ista.exception_classes.KeycloakOperationError --> pyecotrend_ista.exception_classes.KeycloakInvalidTokenError
pyecotrend_ista.exception_classes.KeycloakError --> pyecotrend_ista.exception_classes.KeycloakOperationError
click pyecotrend_ista.exception_classes.KeycloakInvalidTokenError href "" "pyecotrend_ista.exception_classes.KeycloakInvalidTokenError"
click pyecotrend_ista.exception_classes.KeycloakOperationError href "" "pyecotrend_ista.exception_classes.KeycloakOperationError"
click pyecotrend_ista.exception_classes.KeycloakError href "" "pyecotrend_ista.exception_classes.KeycloakError"
Keycloak invalid token exception.
Parameters:
-
(error_message¶str, default:'') –The error message (default is an empty string).
-
(response_code¶int, default:None) –The code of the response (default is None).
-
(response_body¶bytes, default:None) –Body of the response (default is None).
Methods:
-
__str__–Str method.
Source code in src/pyecotrend_ista/exception_classes.py
def __init__(self, error_message="", response_code=None, response_body=None): # numpydoc ignore=ES01,EX01
"""Init method.
Parameters
----------
error_message : str, optional
The error message (default is an empty string).
response_code : int, optional
The code of the response (default is None).
response_body : bytes, optional
Body of the response (default is None).
"""
Exception.__init__(self, error_message)
self.response_code = response_code
self.response_body = response_body
self.error_message = error_message __str__ ¶
__str__() Str method.
Returns:
-
str–String representation of the object.
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self):
"""Str method.
Returns
-------
str
String representation of the object.
"""
if self.response_code is not None:
return f"{self.response_code}: {self.error_message}"
return f"{self.error_message}" deprecated ¶
deprecated(func: Callable[..., T], alias_func: str | None = None) -> Callable[..., T] Decorate a function as deprecated and emit a warning when called.
Parameters:
-
(func¶Callable[..., T]) –The function to be marked as deprecated.
-
(alias_func¶str, default:None) –The real function name to show as deprecated, in case the function was called through an alias.
Returns:
-
Callable[..., T]–A wrapper function that emits a deprecation warning when called.
Source code in src/pyecotrend_ista/exception_classes.py
def deprecated(func: Callable[..., T], alias_func: str | None = None) -> Callable[..., T]: # numpydoc ignore=ES01,PR01,PR02,PR04,PR10,EX01
"""
Decorate a function as deprecated and emit a warning when called.
Parameters
----------
func: Callable[..., T])
The function to be marked as deprecated.
alias_func : str, optional
The real function name to show as deprecated, in case the function was called
through an alias.
Returns
-------
Callable[..., T]
A wrapper function that emits a deprecation warning when called.
"""
def deprecated_func(*args, **kwargs): # numpydoc ignore=ES01,SA01,EX01
"""
Emit a deprecation warning and call the decorated function.
Parameters
----------
*args : tuple
Positional arguments passed to the decorated function.
**kwargs : dict
Keyword arguments passed to the decorated function.
Returns
-------
T
The return value of the decorated function.
"""
if alias_func:
warning_message = (
f"The `{alias_func}` function is deprecated and will be removed in a future release. "
f"Use `{func.__name__}` instead."
)
else:
warning_message = f"The `{func.__name__}` function is deprecated and will be removed in a future release."
warnings.warn(warning_message, category=DeprecationWarning, stacklevel=2)
return func(*args, **kwargs)
return deprecated_func