json2graph.modules.errors
Provide a collection of functions for reporting various error scenarios that can occur during the software’s execution.
These functions are designed to improve the robustness and reliability of the program by providing clear error messages and raising appropriate exceptions when necessary.
Module Contents
Functions
|
Report the error caused when a requirement is not met. As this is a generic function, the error message parameter must be used to identify the error to the user. |
|
Report the error caused when an invalid parameter is passed to a function. E.g., the function accepts (i.e., list_valid_parameters is) ["alfa", "beta"] and the received parameter (invalid_parameter) was "gama". |
|
Report the error caused when an invalid parameter is provided to a switch case (if-else statements). Used to validate parameters. |
|
Report the error caused program cannot read or load the desired content (test_files or directories). |
|
Report the error caused program cannot save or write the desired content (test_files or directories). |
Attributes
- json2graph.modules.errors.LOGGER
- json2graph.modules.errors.report_error_requirement_not_met(error_message)
Report the error caused when a requirement is not met. As this is a generic function, the error message parameter must be used to identify the error to the user.
- Parameters:
error_message (str) – Message to be printed to the user indicating the detected error.
- Raises:
ValueError – Always.
- Return type:
None
- json2graph.modules.errors.report_error_invalid_parameter(invalid_parameter, list_valid_parameters, caller_function_name)
Report the error caused when an invalid parameter is passed to a function. E.g., the function accepts (i.e., list_valid_parameters is) [“alfa”, “beta”] and the received parameter (invalid_parameter) was “gama”.
NOTE 1: This function must be used only for validation of parameters of type string. NOTE 2: caller_function_name can be obtained from ‘current_function = inspect.stack()[0][3]’
- Parameters:
invalid_parameter (str) – Used parameter value that was evaluated as not valid.
list_valid_parameters (list[str]) – List of valid values for the evaluated parameter.
caller_function_name (str) – Name of the function in which the invalid parameter was used.
- Raises:
ValueError – Always.
- Return type:
None
- json2graph.modules.errors.report_error_end_of_switch(invalid_parameter, caller_function_name)
Report the error caused when an invalid parameter is provided to a switch case (if-else statements). Used to validate parameters.
NOTE: caller_function_name can be obtained from ‘current_function = inspect.stack()[0][3]’
- Parameters:
invalid_parameter (str) – Invalid function parameter that caused the error.
caller_function_name (str) – Name of the function in which the invalid parameter was used.
- Raises:
ValueError – Always.
- Return type:
None
- json2graph.modules.errors.report_error_io_read(desired_content, file_description, error)
Report the error caused program cannot read or load the desired content (test_files or directories).
- Parameters:
desired_content (str) – Name of the file used by the IO operation caused the error.
file_description (str) – Description of the file in desired_content.
error (OSError) – Error raised by the IO operation.
- Raises:
OSError – Always.
- Return type:
None
- json2graph.modules.errors.report_error_io_write(desired_content, file_description, error)
Report the error caused program cannot save or write the desired content (test_files or directories).
- Parameters:
desired_content (str) – Name of the file used by the IO operation caused the error.
file_description (str) – Description of the file in desired_content.
error (OSError) – Error raised by the IO operation.
- Raises:
OSError – Always.
- Return type:
None