mirror of https://github.com/pybind/pybind11
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
894 B
42 lines
894 B
#!/usr/bin/env python |
|
from __future__ import print_function |
|
import sys |
|
sys.path.append('.') |
|
|
|
import example |
|
|
|
print("Can we catch a MyException?") |
|
try: |
|
example.throws1() |
|
except example.MyException as e: |
|
print(e.__class__.__name__, ":", e) |
|
print("") |
|
|
|
print("Can we translate to standard Python exceptions?") |
|
try: |
|
example.throws2() |
|
except Exception as e: |
|
print(e.__class__.__name__, ":", e) |
|
print("") |
|
|
|
print("Can we handle unknown exceptions?") |
|
try: |
|
example.throws3() |
|
except Exception as e: |
|
print(e.__class__.__name__, ":", e) |
|
print("") |
|
|
|
print("Can we delegate to another handler by rethrowing?") |
|
try: |
|
example.throws4() |
|
except example.MyException as e: |
|
print(e.__class__.__name__, ":", e) |
|
print("") |
|
|
|
print("Can we fall-through to the default handler?") |
|
try: |
|
example.throws_logic_error() |
|
except Exception as e: |
|
print(e.__class__.__name__, ":", e) |
|
print("") |
|
|
|
|