I want to patch a library to catch the built-in ConnectionError (which inherits from OSError).
So far so good. As it happens, the library has a "self-defined" Exception that is also called ConnectionError:
class LibraryError(Exception):
pass
class ConnectionError(LibraryError):
pass
I guess, if I now tried to catch a ConnectionError
, doing something like
try:
do_something()
except ConnectionError as e:
try_to_get_it_right_again()
I would only catch the self-defined ConnectionError
, which inherits from LibraryError
. (Disclaimer: I have to admit, I haven't tested that myself, as I didn't know how).
How would I get Python to catch the built-in ConnectionError
?