Python How To Exclude Exceptions From "catch All"
Lets say I have this: try: result = call_external_service() if not result == expected: raise MyException() except MyException as ex: # bubble up raise ex ex
Solution 1:
Your problem seems to be that you are wrapping too much code in your try block. What about this?:
try:
result = call_external_service()
except Exception:
# unexpected exceptions from calling external service
do_some_logging()
if result != expected:
raise MyException()
Post a Comment for "Python How To Exclude Exceptions From "catch All""