I am currently investigating alternative methods for intercommunication between different components within a project by leveraging exception raising and capturing mechanisms.
While I acknowledge that this approach diverges from the conventional use of exceptions primarily intended for error handling, I am exploring its potential validity.
To illustrate, envision a scenario where an exception is raised within a file named file1.py:
try:
raise CustomError
except CustomError as exc:
# Obtain attributes from file2.py and file3.py
print(exc.attr2, exc.attr3)
This exception is subsequently accessed and managed in file2.py and file3.py:
# file2.py
error: CustomError
error.attr2 = "test!"
# file3.py
error: CustomError
error.attr3 = "test!"
Essentially, I am seeking a method to govern the propagation of Python's exception handling flow, as well as the normal execution flow, facilitating execution to continue after the raise keyword is invoked.
Additionally, I aim to establish a mechanism to handle exceptions raised once, yet handled multiple times throughout the project.
While I acknowledge that historically, such techniques have not seamlessly aligned with Python's exception handling paradigm, I am enthusiastic about exploring innovative approaches.
If you happen to be exploring possibilities in this domain, I am keen to engage in further discussion and exchange insights.