-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexcept2.py
55 lines (39 loc) · 1.06 KB
/
except2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# try:
# causeError(0)
# except ZeroDivisionError:
# print("something to do with zero division errors")
# except TypeError:
# print("Something to do with type errors")
# except Exception as ex:
# print(type(ex))
# print(f"Some error happened: {ex}")
# # 1/0
# print("Hello!")
# # decorator function
# def handleExceptions(func):
# def wrapper(*args):
# try:
# func(*args)
# except ZeroDivisionError:
# print("something to do with zero division errors")
# except TypeError:
# print("Something to do with type errors")
# except Exception as ex:
# print(type(ex))
# print(f"Some error happened: {ex}")
# return wrapper
# @handleExceptions
# def myFunction():
# print("I am in myFunction")
# @handleExceptions
# def causeError(n):
# 1 + n
# 1/n
# myFunction()
# causeError(0)
# causeError('a')
# class CustomException(Exception):
# pass
# def causeError():
# raise CustomException("This is a custom exception")
# causeError()