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 ¶
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 ¶
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 ¶
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 ¶
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)
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)
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)
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)
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)
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)
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)
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