print_instance_connection_error¶
- pyrcs.utils.print_instance_connection_error(update=False, verbose=False, e=None, raise_error=False)[source]¶
Handles connection errors during data retrieval or update processes.
This function processes connection failures by printing targeted feedback based on the verbosity configuration, while offering options to suppress or propagate errors.
- Parameters:
update (bool) – Indicates whether the error occurred during a data update. Defaults to
False.verbose (bool | int) – Whether to print relevant information to the console. Defaults to
False.e (Exception | None) – An optional exception instance to display or raise.
raise_error (bool) – Whether to raise the exception; if
False(default), the error is suppressed.
- Returns:
None if the exception is suppressed.
- Return type:
None
- Raises:
ConnectionError – If
raise_errorisTrueand no exceptioneis provided.Exception – Re-raises
eifraise_errorisTrue.
Examples:
>>> from pyrcs.utils import print_instance_connection_error >>> print_instance_connection_error(verbose=True) The Internet connection is not available. >>> print_instance_connection_error(update=True, verbose=True) The Internet connection is not available. Failed to update the data. >>> print_instance_connection_error(update=True, verbose=2, raise_error=True) Failed. The Internet connection is not available. Failed to update the data. Traceback (most recent call last): ... ... TypeError: exceptions must derive from BaseException