Created
August 3, 2015 10:40
-
-
Save mattbennett/d42030daecb0ee773dce to your computer and use it in GitHub Desktop.
Raising vs reraising
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def foo(): | |
bar() | |
def bar(): | |
baz() | |
def baz(): | |
raise Exception("whoops") | |
def raises(): | |
try: | |
foo() | |
except Exception: | |
raise | |
def reraises(): | |
try: | |
foo() | |
except Exception as exc: | |
raise exc | |
if sys.argv[1] == "raise": | |
raises() | |
elif sys.argv[1] == "reraise": | |
reraises() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
vs