2014-04-29 03:28:31 +03:00
|
|
|
class MyExc(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
e = MyExc(100, "Some error")
|
|
|
|
print(e)
|
2014-05-02 01:51:25 +03:00
|
|
|
print(repr(e))
|
2014-04-29 03:28:31 +03:00
|
|
|
print(e.args)
|
2014-05-02 02:30:28 +03:00
|
|
|
|
|
|
|
try:
|
|
|
|
raise MyExc("Some error")
|
|
|
|
except MyExc as e:
|
|
|
|
print("Caught exception:", repr(e))
|
|
|
|
|
|
|
|
try:
|
|
|
|
raise MyExc("Some error2")
|
|
|
|
except Exception as e:
|
|
|
|
print("Caught exception:", repr(e))
|
|
|
|
|
|
|
|
try:
|
|
|
|
raise MyExc("Some error2")
|
|
|
|
except:
|
|
|
|
print("Caught user exception")
|