blob: d4ee5f8531a4ac6a79b026da9819dbce762eb741 [file] [log] [blame]
Pim Schellart5a7d17f2016-06-17 17:35:59 -04001#!/usr/bin/env python
2from __future__ import print_function
3import sys
4sys.path.append('.')
5
6import example
7
8print("Can we catch a MyException?")
9try:
10 example.throws1()
11except example.MyException as e:
12 print(e.__class__.__name__, ":", e)
13print("")
14
15print("Can we translate to standard Python exceptions?")
16try:
17 example.throws2()
18except Exception as e:
19 print(e.__class__.__name__, ":", e)
20print("")
21
22print("Can we handle unknown exceptions?")
23try:
24 example.throws3()
25except Exception as e:
26 print(e.__class__.__name__, ":", e)
27print("")
28
29print("Can we delegate to another handler by rethrowing?")
30try:
31 example.throws4()
32except example.MyException as e:
33 print(e.__class__.__name__, ":", e)
34print("")
35
36print("Can we fall-through to the default handler?")
37try:
38 example.throws_logic_error()
39except Exception as e:
40 print(e.__class__.__name__, ":", e)
41print("")
42