Exasol Error Reporting
Exasol Error Reporting is a Python library designed to standardize error messages with structured error codes, messages, and mitigation hints. It ensures uniformity across applications by enforcing a specific error code format. The current version is 1.1.0, and it follows an active release cadence, typically updating dependencies and addressing security concerns as needed.
Common errors
-
ModuleNotFoundError: No module named 'exasol_error_reporting_python'
cause The Python package was renamed from `exasol-error-reporting-python` to `exasol-error-reporting` in version 0.4.0. Your code is likely using the old import path.fixUpdate your `pip install` command to `pip install exasol-error-reporting` and change all import statements from `from exasol_error_reporting_python import ...` to `from exasol.error_reporting import ...`. -
TypeError: ExaError.__init__() got an unexpected keyword argument 'error_code'
cause This error can occur if you are using an older API pattern with a newer version of the library. The API was reworked in 0.4.0.fixEnsure you are using the modern `ExaError(code, message)` constructor. Refer to the quickstart example for current usage. -
ValueError: Invalid error code format 'E-XX-123'
cause The error code provided does not match the required pattern `E-<THREE_LETTER_COMPONENT>-<NUMBER>` (e.g., `E-TEST-1`). The component part must be exactly three uppercase letters.fixCorrect the error code to follow the specified format, ensuring the component part (e.g., 'TEST' in 'E-TEST-1') consists of exactly three uppercase letters.
Warnings
- breaking Python 3.9 support was dropped.
- breaking The package name and import path changed from `exasol-error-reporting-python` to `exasol-error-reporting`.
- gotcha Error codes must adhere to a specific format (e.g., `E-ABC-1`). Incorrect formats will raise a `ValueError`.
Install
-
pip install exasol-error-reporting
Imports
- ExaError
from exasol_error_reporting_python import ExaError
from exasol.error_reporting import ExaError
Quickstart
from exasol.error_reporting import ExaError
def my_faulty_function(param_value):
if param_value is None:
raise ExaError("E-TEST-1", "Input parameter 'param_value' must not be None.") \
.add_mitigation("Provide a valid non-null value for 'param_value'.") \
.add_parameter("received_value", "None")
return f"Processed: {param_value}"
# Example Usage:
try:
my_faulty_function(None)
except ExaError as e:
print(f"Caught ExaError: {e.error_code} - {e.message}")
for mitigation in e.mitigations:
print(f" Mitigation: {mitigation}")
for param, value in e.parameters.items():
print(f" Parameter {param}: {value}")
try:
result = my_faulty_function("hello")
print(result)
except ExaError as e:
print(f"Unexpected error: {e}")