Exceptions¶
pyecotrend_ista.exception_classes ¶
Exception Class.
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.
__str__ ¶
__str__() -> str
Return a string representation of the error..
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self) -> str:
"""Return a string representation of the error.."""
return "Server error occurred during the request"
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.
__str__ ¶
__str__() -> str
Return a string representation of an authentication error.
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self) -> str:
"""Return a string representation of an authentication error."""
return "An authentication error occurred during the request"
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.
__str__ ¶
__str__() -> str
Return a string representation of parser error.
Source code in src/pyecotrend_ista/exception_classes.py
def __str__(self) -> str:
"""Return a string representation of parser error."""
return "Error occurred during parsing of the request response"
KeycloakError ¶
KeycloakError(error_message='', response_code=None, response_body=None)
Base class for custom Keycloak errors.
Parameters:
-
error_message
(
, default:str ''
) –The error message (default is an empty string).
-
response_code
(
, default:int None
) –The code of the response (default is None).
-
response_body
(
, default:bytes None
) –Body of the response (default is None).
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
(
, default:str ''
) –The error message (default is an empty string).
-
response_code
(
, default:int None
) –The code of the response (default is None).
-
response_body
(
, default:bytes None
) –Body of the response (default is None).
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
(
, default:str ''
) –The error message (default is an empty string).
-
response_code
(
, default:int None
) –The code of the response (default is None).
-
response_body
(
, default:bytes None
) –Body of the response (default is None).
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
(
, default:str ''
) –The error message (default is an empty string).
-
response_code
(
, default:int None
) –The code of the response (default is None).
-
response_body
(
, default:bytes None
) –Body of the response (default is None).
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
(
, default:str ''
) –The error message (default is an empty string).
-
response_code
(
, default:int None
) –The code of the response (default is None).
-
response_body
(
, default:bytes None
) –Body of the response (default is None).
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
(
, default:str ''
) –The error message (default is an empty string).
-
response_code
(
, default:int None
) –The code of the response (default is None).
-
response_body
(
, default:bytes None
) –Body of the response (default is None).
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
(
, default:str ''
) –The error message (default is an empty string).
-
response_code
(
, default:int None
) –The code of the response (default is None).
-
response_body
(
, default:bytes None
) –Body of the response (default is None).
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
(
, default:str 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