I'm decently new to Python, and I have a question over the implementation of a certain exception methodology. This is the code (shortened):
class OurException(Exception): """User defined Exception""" .... def get_single_value(command: str, connect_string: str, logger: Logger = None, custom_exception: Exception = OurException) -> Tuple[int, str]: .... raise custom_exception("Errors in script\n\nexit .....") The exception parameter that I defaulted to OurException cannot be raised this way. However, when I change the custom_exception in the last line to either Exception or OurException, the problem disappears.
In an OOP context, I'd say that as I have defined the parameter to be an Exception, and an Exception is callable that way, it is guaranteed to work. However, my python interpreter and IDE disagree (Pycharm, Python 3.7).
Something is not working the way I think it is working, and I'm interested what that is.
OurExceptiondoesn't have typeException.Exceptionis the (super)type of an instance ofOurException, not of the class.