Is there a way to throw an exception in a try / except block from one other than the next?
I want to catch a specific error, and then perform general error handling.
"raise" allows you to exclude "bubble up" for an external try / except, but not inside the try / except block that caused the error.
Ideally, there should be something like this:
import logging def getList(): try: newList = ["just", "some", "place", "holders"]
The problem is that when an IndexError gets bound to the first, except mine, the general error handling in the second exclusive block is not applied.
The only workaround I have now is to include a common error handling code in the first block. Even if I pack it in my own function block, it still seems less elegant ...
source share