Skip to content

Instantly share code, notes, and snippets.

@svetlyak40wt
Created March 23, 2016 16:18
Show Gist options
  • Save svetlyak40wt/1dd8547bfcd2048ab1ee to your computer and use it in GitHub Desktop.
Save svetlyak40wt/1dd8547bfcd2048ab1ee to your computer and use it in GitHub Desktop.
Example of nested try/except in python
# guess what will be at the output?
class FooError(RuntimeError):
pass
class BarError(RuntimeError):
pass
def foo():
raise FooError()
def bar():
raise BarError()
try:
foo()
except FooError:
try:
bar()
except BarError:
print('bar catched')
raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment