I want to handle a specific exception in a certain way, and generically log all the others. This is what I have:
class MyCustomException(Exception): pass
try:
something()
except MyCustomException:
something_custom()
except Exception as e:
#all others
logging.error("{}".format(e))
The problem is that even MyCustomException will be logged because it inherits from Exception. What can I do to avoid that?
something()? If it's raising aMyCustomExceptionthis code works properly.