1class MyExc(Exception): 2 pass 3 4e = MyExc(100, "Some error") 5print(e) 6print(repr(e)) 7print(e.args) 8 9try: 10 raise MyExc("Some error", 1) 11except MyExc as e: 12 print("Caught exception:", repr(e)) 13 14try: 15 raise MyExc("Some error2", 2) 16except Exception as e: 17 print("Caught exception:", repr(e)) 18 19try: 20 raise MyExc("Some error2") 21except: 22 print("Caught user exception") 23