I have a code like this:
try:
return make_success_result()
except FirstException:
handle_first_exception()
return make_error_result()
except SecondException:
handle_second_exception()
return make_error_result()
And I wonder if I can achieve this:
try:
# do something
except Error1:
# do Error1 specific handling
except Error2:
# do Error2 specific handling
else:
# do this if there was no exception
????:
# ALSO do this if there was ANY of the listed exceptions (e.g. some common error handling)
Thus, the code is executed in one of the following sequences:
try > else > finally
try > except > ???? > finally
EDIT: My point is that a block ????should execute immediately after ANY of the blocks except, which means it's an addition to error handling, not a substitution.
source
share