How to re-catch already caught exception in Python?

Viewed 176

I have a code similar to the following:

try:
    something()
except DerivedException as e:
    if e.field1 == 'abc':
        handle(e)
    else:
        # re-raise with catch in the next section!
except BaseException as e:
    do_some_stuff(e)

Where DerivedException is derived from BaseException.

So, like the comment in the code mentions - I want to re-raise the exception from inside of the first except-section and catch it again inside the second except-section.

How to do that?

3 Answers
Related