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.
23 lines
376 B
23 lines
376 B
11 years ago
|
class MyExc(Exception):
|
||
|
pass
|
||
|
|
||
|
e = MyExc(100, "Some error")
|
||
|
print(e)
|
||
11 years ago
|
print(repr(e))
|
||
11 years ago
|
print(e.args)
|
||
11 years ago
|
|
||
|
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")
|