2014-04-28 18:28:31 -06:00
|
|
|
class MyExc(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
e = MyExc(100, "Some error")
|
|
|
|
print(e)
|
2014-05-01 16:51:25 -06:00
|
|
|
print(repr(e))
|
2014-04-28 18:28:31 -06:00
|
|
|
print(e.args)
|
2014-05-01 17:30:28 -06:00
|
|
|
|
|
|
|
try:
|
2018-08-16 23:46:04 -06:00
|
|
|
raise MyExc("Some error", 1)
|
2014-05-01 17:30:28 -06:00
|
|
|
except MyExc as e:
|
|
|
|
print("Caught exception:", repr(e))
|
|
|
|
|
|
|
|
try:
|
2018-08-16 23:46:04 -06:00
|
|
|
raise MyExc("Some error2", 2)
|
2014-05-01 17:30:28 -06:00
|
|
|
except Exception as e:
|
|
|
|
print("Caught exception:", repr(e))
|
|
|
|
|
|
|
|
try:
|
|
|
|
raise MyExc("Some error2")
|
|
|
|
except:
|
|
|
|
print("Caught user exception")
|