Because all of your exceptions inherit directly from the Exception class, it's impossible to write a small exception handler for your library. As it stands, I'm forced to either handle each exception explicitly or catch Exception directly -- both of which are undesirable.
I suggest something like this:
class IPWhoisException(Exception):
pass
class NetError(IPWhoisException):
"""
An Exception for when a parameter provided is not an instance of
ipwhois.net.Net.
"""
class IPDefinedError(IPWhoisException):
"""
An Exception for when the IP is defined (does not need to be resolved).
"""
# ... etc ...
Which would then allow me to do this:
try:
# ipwhois lookup
except IPWhoisException:
# handle it
Problem
Because all of your exceptions inherit directly from the Exception class, it's impossible to write a small exception handler for your library. As it stands, I'm forced to either handle each exception explicitly or catch
Exception
directly -- both of which are undesirable.I suggest something like this:
Which would then allow me to do this:
Thanks