I have the following scenario:
Program A uses library L. Library L defines some exceptions. If an exception defined in L is raised in A, I want to serialize it into a json and send it via some channel (e.g. redis). This exception is then received by some program B where I want to deserialize the exception and do something with it. In order to be able to deserialize the exception, B needs to know all the exceptions defined in L. How would I get all exceptions from L? Would it make sen to loop through all members of L and check if they are subclasses of Exception?
In order to de-serialize the exceptions in B, L must be importable from B, with the same full name that it is importable in A.
If both A, B and L are part of the same Python package, it would just work. If A and B are in different packages, you'd better refactor L to live in its own stand-alone package (not depending from A), and make it a dependency of B.
Python: How do I import all exception from some module?